Private Sub Command1_Click() X = 5: Y = 3 Call proc(X, Y) Label1.Caption = X Label2.Caption = Y End Sub Private Sub proc(ByVal a As Integer, ByVal b As Integer) X = a * a Y = b + b
如果有前面加多这句Private Y As Integer就是6!真的好容易犯错啦!怎样才能区分呢?因为没学过,自学看书很容易就忽略了。。。就像另一道题是不是也要看传址与传值吗?怎样才能很好的掌握这类题型呢?运行结果总是出乎我的计算的? Private Sub Form_Click() Dim a As Integer, b As Integer a = 20: b = 50 p1 a, b p2 a, b p3 a, b Print "a="; a, "b="; b End Sub Sub p1(x As Integer, ByVal y As Integer) x = x + 10 y = y + 20 End Sub Sub p2(x As Integer, ByVal y As Integer) x = x + 10 y = y + 20 End Sub Sub p3(x As Integer, ByVal y As Integer) x = x + 10 y = y + 20 End Sub