Tutorial by Examples

Passing ByRef or ByVal indicates whether the actual value of an argument is passed to the CalledProcedure by the CallingProcedure, or whether a reference (called a pointer in some other languages) is passed to the CalledProcedure. If an argument is passed ByRef, the memory address of the argument i...
Default modifier If no modifier is specified for a parameter, that parameter is implicitly passed by reference. Public Sub DoSomething1(foo As Long) End Sub Public Sub DoSomething2(ByRef foo As Long) End Sub The foo parameter is passed ByRef in both DoSomething1 and DoSomething2. Wa...
Passing by value When a value is passed ByVal, the procedure receives a copy of the value. Public Sub Test() Dim foo As Long foo = 42 DoSomething foo Debug.Print foo End Sub Private Sub DoSomething(ByVal foo As Long) foo = foo * 2 End Sub Calling the above Test...

Page 1 of 1