Basic handles Functions and Subs pretty much the same way, except Functions return a value...
A sub is like a void function in C and Java
With the following 2 procedures:
Public Sub MySub(X as integer, Y as Integer)
...
End Sub
Public Function MyFunction(X as Integer, Y as Integer) As Integer
...
End Sub
You can call them like this...
With Parentheses... Call MySub(X, Y)
Z = MyFunction(X, Y)
Or without... MySub X, Y
MyFunction X, Y
*Note: If you call a sub with parentheses, you MUST use CALL (as shown above)
On the flip side, If you want a function to return a value, you must Use Parentheses...
You Can also Call them like so... MySub X, MyFunction(A, B)
As far as calling from other procedures, that is a matter of scope...
Any Sub/Function can call any other Sub/Function within the same module, no matter what...
If you need to call it from a different module, use Public Public Sub MySub(X as integer, Y as Integer)
...
End Sub
If don't want it to be called from any other module, use Private Private Sub MySub(X as integer, Y as Integer)
...
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.