...but is also valid for all members of VB family.
Dim varA, strMsg
varA = Int(InputBox ("Input the initial value:"))
strMsg ="'varA' initial: " & varA & Chr(13) & Chr(10)
varA = TransAVal(varA) 'varA ia valoarea functiei / varA it takes the function's value
strMsg = strMsg & "'varA' after TransAVal: " & varA & Chr(13) & Chr(10)
varA = TransARef(varA) 'varA ia valoarea functiei / varA it takes the function's value
strMsg = strMsg & "'varA' after TransARef: " & varA & Chr(13) & Chr(10)
ValA varA 'varA isi pastreaza valoarea / varA keeps its value
strMsg = strMsg & "'varA' after ValA: " & varA & Chr(13) & Chr(10)
RefA varA 'varA ia valoarea finala a parametrului din functia RefA / varA it takes the final value of the RefA function parameter
strMsg = strMsg & "'varA' after RefA: " & varA
WScript.Echo strMsg
Function TransARef(ByRef x)
TransARef = x + 1
End Function
Function TransAVal(ByVal x)
TransAVal = x + 1
End Function
Sub ValA(ByVal x)
x = x + 1
End Sub
Sub RefA(ByRef x)
x = x + 1
End Sub
Conclusion:
ByRef and BvVal have no influence if you return the function to assign it to a value. This is the most common situation.
Niciun comentariu:
Trimiteți un comentariu