VB程序找错题 请高手来 急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/28 01:43:44
通过调用过程swap进行两个数值互相交换
Public Sub swap(x As Integer, y As Integer)
Dim t As Integer
x = t
x = y
y = t
End Sub

Private Sub Form_Click()
Dim a As Integer, b As Integer
a = 10
b = 20
swap(a,b)
Print "a="; a, "b="; b
End Sub
哪里错了啊 谢谢

Public Sub Swap(byref x As Integer, byref y As Integer)
Dim t As Integer
t = x '你看你自己这里些成什么了
x = y
y = t
End Sub

Private Sub Form_Click()
Dim a As Integer, b As Integer
a = 10
b = 20
Call Swap(a, b) '奇怪,这里不用call就报错
Print "a="; a, "b="; b
End Sub

call swap(a,b)
或者
swap a,b

函数出错...
t=x
x=y
y=t

函数调用:
call swap (a,b)
swap a,b

t=x:x=y:y=t

call swap(a,b)'省略call的话就不要带括号!!