CALL procname ([arglist])

Transfers control to a subroutine or function.

procnameThe name of the procedure.
arglist(Optional) The comma delimited list of variables to pass to the procedure.

* Using the Call keyword is considered redundant now, which is a shame. because it does make your code more readable.
* This syntax actually comes from the days of BASIC when every line had to start with a keyword.
* When you transfer control without using "Call" you do not have to include parentheses around your arguments.
* This can be used to call functions as well as subroutines.
* When you call a function the returned value is discarded.
* For the Microsoft documentation refer to

procname arg1, arg2 
Call procname(arg1, arg2)

Sub Testing()
    Call MySubroutine1

    MySubroutine2 20
    Call MySubroutine2(20)

'ignores return value
    Call MyFunction1

'ignores return value
    MyFunction2 "text"
    Call MyFunction2("text")
End Sub

Sub MySubroutine1()
End Sub

Sub MySubroutine2(ByVal number As Double)
End Sub

Function MyFunction1() As String
    MyFunction1 = "text"
End Function

Function MyFunction2(ByVal str As String) As String
    MyFunction2 = "text"
End Function

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top