vb参数传递

来源:百度知道 编辑:UC知道 时间:2024/06/14 01:21:09
Private Sub Command1_Click()
Dim c As Single
c = CSng(Text1.Text)
mycos c
End Sub

Private Sub mycos(a As Single)
Dim b As Single
b = Cos(a)
Text2.Text = b
End Sub
在这个过程中,参数是怎样传递的,我想了解一下?

vb默认是地址传递,把c的存放地址传递给a,所以对变量a的操作(如a=a+1),其实就是对变量c的操作。

Private Sub mycos(a As Single)

系统默认是地址传送,即byref时省略

Private Sub mycos([byref] a As Single)

带byval是值传送

Private Sub mycos(byval a As Single)