您好,登錄后才能下訂單哦!
ByVal 關(guān)鍵字的參數(shù)是值傳參,ByRef 關(guān)鍵字的參數(shù)是地址傳參。
ByVal的參數(shù),是指定參數(shù)類型的值,不會改變傳參對象的原地址值;
ByRef的參數(shù),是指定原地址入?yún)?,是直接使用原地址對象,如果在方法里修改該對象的話,原地址的對象值也會改變,使用時慎用。
例子:
Public Class Form4
Private number As Integer = 1
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
test2(number)
MsgBox(number)
test(number)
MsgBox(number)
End Sub
Private Sub test(ByVal num As Integer)
num += 1
End Sub
Private Sub test2(ByRef num As Integer)
num += 1
End Sub
End Class
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。