Pass variable by value : ByVal ByRef « Language Basics « VBA / Excel / Access / Word






Pass variable by value

 
Sub CubeRoot(ByVal dblNumber As Double)

    dblNumber = dblNumber ^ (1 / 3)

End Sub

Sub CubeRootWrapper()

    Dim dblVariable As Double
    dblVariable = 8

    Debug.Print "Before: " & dblVariable
    CubeRoot dblVariable
    Debug.Print "After: " & dblVariable

End Sub

 








Related examples in the same category

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