T
topalps
I'm confused with 'byref' now. the i should be changed, doesn't it? but
it turns out that i never changed. why? dose referenece really work in
vba?
Sub try()
Dim i As Integer
i = 1
Debug.Print i
f1 (i)
Debug.Print i
Dim j As Integer
f2(i)
Debug.Print i
End Sub
Private Function f1(ByVal n As Integer)
n = n + 1
End Function
Private Function f2(ByRef n As Integer) As Integer
n = n + 1
End Function
it turns out that i never changed. why? dose referenece really work in
vba?
Sub try()
Dim i As Integer
i = 1
Debug.Print i
f1 (i)
Debug.Print i
Dim j As Integer
f2(i)
Debug.Print i
End Sub
Private Function f1(ByVal n As Integer)
n = n + 1
End Function
Private Function f2(ByRef n As Integer) As Integer
n = n + 1
End Function