Answers for "byval by ref vba"

VBA
0

vba byref byval

Sub TestMe()
    Dim sString As String
    sString = "Initial value"
    
    Call EstimVal(sString)
    Debug.Print sString          ' "Initial value"

    sString = "Initial value"
    Call EstimRef(sString)       ' ByRef with call
    Debug.Print sString          ' "ByRef"
   
    sString = "Initial value"
    EstimRef (sString)           ' ByRef without call
    Debug.Print sString          ' "Initial value"
   
    sString = "Initial value"
    Call EstimRef((sString))     ' ByRef with call and (): sString evaluated first
    Debug.Print sString          ' "Initial value"
End Sub
'--------------------------------------------------------------
Function EstimVal(ByVal pVar As String)
   pVar = "ByVal"
End Function
Function EstimRef(ByRef pVar As String)
   pVar = "ByRef"
End Function
Posted by: Guest on January-22-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language