ByVal is transmitted by value , the original value is not changed during the pass, and only a copy is transmitted.
Instead of ByRef , the latter is the same memory address from the memory address.
ByVal and ByRef (default value)
These two are the parameters passed by the child procedure when the parameters are passed by the specified
ByVal (passed by value)
ByRef (delivered by address)
See the following example for details:
Dim A as integer,b as Integer
A=1
b=2
Call Fun01 (A, B)
The result of Print A, B ' is 2 3 (the change in the parameters affects the argument, i.e. now A=2,B=3)
Call Fun02 (A, B)
Pring A, B ' gets the same result as above, 2 3 (the change of the parameter does not affect this argument)
Sub Fun01 (I as integer,j as Integer) ' default, the address is passed
I=i+1
J=j+1
End Sub
Sub fun02 (ByVal I as Integer,byval J as Integer) ' passed by value
I=i+1
J=j+1
End Sub
(reproduced) The difference between ByVal and ByRef in VB