ByVal and ByRef : ByVal ByRef « Language Basics « VBA / Excel / Access / Word






ByVal and ByRef

 
Private Sub Main()
    Dim num1 As Integer
    Dim num2 As Integer
    num1 = 10
    num2 = 15
    Call passByRef(num1)
    Call passByVal(num2)
    MsgBox (num1 & "  " & num2)
End Sub
Private Sub passByRef(ByRef num3 As Integer)
    num3 = 20
End Sub
Private Sub passByVal(ByVal num2 As Integer)
    num2 = 20
End Sub

 








Related examples in the same category

1.Pass variable by value
2.Creating Your Own VBA Functions: ByVal
3.Passing Arguments with ByVal and ByRef