Option ExplicitPrivate Sub Command1_Click()
Dim A As Integer, B As Integer, K As Integer
A = 2: B = 4
K = Fun((A), B) + Fun(A, B)
Print K
End Sub
Private Function Fun(N As Integer, M As Integer) As Integer
Static K As Integer
N = N + M
K = K + N
M = M + K
Fun = N + M
Print Fun; N; M
End Function
Dim A As Integer, B As Integer, K As Integer
A = 2: B = 4
K = Fun((A), B) + Fun(A, B)
Print K
End Sub
Private Function Fun(N As Integer, M As Integer) As Integer
Static K As Integer
N = N + M
K = K + N
M = M + K
Fun = N + M
Print Fun; N; M
End Function
传值在fun函数返回时不改变A变量的原有值,传地址在fun函数返回时会改变A变量的原有值。
传值在fun函数返回时不改变A变量的原有值,传地址在fun函数返回时会改变A变量的原有值
这个有点麻烦,耐心点学就行啦
加油!
vb默认是byref,没有byref和byval的都按byref处理
除非你声明是byval