簡單的說byref可以雙向傳遞,byval是單向傳遞。byval 是值傳遞,byref 是引用傳遞。比如一個簡單地列子你就會: sub Change(byval a as integer) as integer a= a +10 end sub sub Change1(byref a as integer) as integer a= a+10 end sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dim int As Integer = 1 change(int) msgBox(int) change1(int) MsgBox(int) end Subend class這時顯示的結果分別是1 和 11
簡單的說byref可以雙向傳遞,byval是單向傳遞。byval 是值傳遞,byref 是引用傳遞。比如一個簡單地列子你就會: sub Change(byval a as integer) as integer a= a +10 end sub sub Change1(byref a as integer) as integer a= a+10 end sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dim int As Integer = 1 change(int) msgBox(int) change1(int) MsgBox(int) end Subend class這時顯示的結果分別是1 和 11