Difference between functions and sub

The major difference between function and sub is that function return values while the sub doesn't.

However by using global variable, dictionary object or byref  methods we can get back the values from the subs.

E.g
We can using following in for defining and getting a value back from the function


print add1(2,3)

Public function add1(a,b)
add1= a+b
End Function

but by the same way we can't define a sub. Following code will through an error if executed.


a=add2(2,3)
Public Sub add2(a,b)
mul=a*b
End Sub

Comments

Popular posts from this blog

Arrays

What is the difference between eval, execute and executeglobal.

Sample Test Strategy for a MicroService Project with APIs only