byval 对引用类型无效么??
Public Class Class2
Public a As Integer
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New Class2
a.a = 5
ccc(a)
TextBox1.Text = a.a
End Sub
Public Sub ccc(ByVal b As Class2)
b.a = 3
End Sub
End Class
输出3
[解决办法]
我的理解是这里的b只是形参,所以只存在一个引用a,不管用ByRef还是ByVal都是输出3。