麻烦解释这个程序Private Sub pl(x As Integer,ByVal y As Integer)x = 4:y = 5:z = 6End SubPrivate Sub Command1_Click()Dim x As Integer,y As Integerx = 1:y = 2:z = 3Print x,y,zCall pl(y,z)Print x,y,zEnd Sub
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 05:52:26
麻烦解释这个程序Private Sub pl(x As Integer,ByVal y As Integer)x = 4:y = 5:z = 6End SubPrivate Sub Command1_Click()Dim x As Integer,y As Integerx = 1:y = 2:z = 3Print x,y,zCall pl(y,z)Print x,y,zEnd Sub
麻烦解释这个程序
Private Sub pl(x As Integer,ByVal y As Integer)
x = 4:y = 5:z = 6
End Sub
Private Sub Command1_Click()
Dim x As Integer,y As Integer
x = 1:y = 2:z = 3
Print x,y,z
Call pl(y,z)
Print x,y,z
End Sub
麻烦解释这个程序Private Sub pl(x As Integer,ByVal y As Integer)x = 4:y = 5:z = 6End SubPrivate Sub Command1_Click()Dim x As Integer,y As Integerx = 1:y = 2:z = 3Print x,y,zCall pl(y,z)Print x,y,zEnd Sub
Private Sub pl(x As Integer,ByVal y As Integer) '不加任何修饰符号就默认是ByRef
'byval表示按值传递,过程内对这个变量的值做任何改动,byref表示按引用传递,过程内对这个变量的改动会影响调用它的过程里的变量的值
x = 4:y = 5:z = 6'这里x=4会改动调用者的值,y则不会改变
End Sub
Private Sub Command1_Click()
Dim x As Integer,y As Integer
x = 1:y = 2:z = 3
Print x,y,z'此时输出 1 2 3
Call pl(y,z)'调用这个时y 对应参数里的x,z对应参数里的y;在上面的过程里,x也就是这里的y是被修改的,修改成了4,所以y就等于4
Print x,y,z'所以此时输出是1 4 3
End Sub