ByVal: Byval refers to the actual value of the variable.
Example:
Function fun1(Byref variable1)
variable1=variable1+1
End function
Dim x
x=3
'Pass parameter to the function byval
fun1 x
Msgbox x
Result:3
ByRef: ByRef refers to the location of where the value is stored.
Examples:
Function fun1(Byref variable1)
variable1=variable1+1
End function
Dim x
x=3
'Pass parameter to the function byref
fun1 x
Msgbox x
Result:4
Example:
Function fun1(Byref variable1)
variable1=variable1+1
End function
Dim x
x=3
'Pass parameter to the function byval
fun1 x
Msgbox x
Result:3
ByRef: ByRef refers to the location of where the value is stored.
Examples:
Function fun1(Byref variable1)
variable1=variable1+1
End function
Dim x
x=3
'Pass parameter to the function byref
fun1 x
Msgbox x
Result:4
No comments:
Post a Comment
Note: only a member of this blog may post a comment.