ByVal 与 ByRef(默认值) 的区别
'ByVal 与 ByRef(默认值) 的区别
'ByVal 按值传递 不改变实参
'ByRef 按地址传递 改变实参
Private Sub Form_Load()
Me.Show
Dim A As Integer, B As Integer
A = 1
B = 2
Call AAA(A, B)
Print A, B '得到的结果是2,3
A = 1
B = 2
Call BBB(A, B)
Print A, B '得到的结果是1, 2
End Sub
Sub AAA(I As Integer, J As Integer) '默认,则按址传递
I = I + 1
J = J + 1
End Sub
Sub BBB(ByVal I As Integer, ByVal J As Integer)
I = I + 1
J = J + 1
End Sub