请看下面的代码:
Public Class TypeTest
Public variable1 As String
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim t1 As TypeTest = New TypeTest
Test(t1)
MsgBox(t1.variable1)
End Sub
Public Sub Test(ByVal t1 As TypeTest)
t1.Variable1 = "Thursday"
End Sub
End Class
form_load 中的消息框打印:Thursday,表示对象(TypeTest)是通过引用传递的。在调用的函数中使用 ByVal 和 ByRef 的 t1 争论有什么区别: