本程序的功能为单击窗体,分别调用Swap1和Swap2子过程,使Form1的输出结果为
A1=10 B1=20
A2=20 B2=10
请将程序补充完整。
Public Sub Swap1(【1】)
Dim t As Integer
t = x: x = y: y = t
End Sub
Public Sub Swap2(【2】)
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
【3】
Form1.Print "A1="; a, "B1="; b
call swap2(a,b)
Form1.Print "A2="; a, "B2="; b
End Sub
A1=10 B1=20
A2=20 B2=10
请将程序补充完整。
Public Sub Swap1(【1】)
Dim t As Integer
t = x: x = y: y = t
End Sub
Public Sub Swap2(【2】)
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
【3】
Form1.Print "A1="; a, "B1="; b
call swap2(a,b)
Form1.Print "A2="; a, "B2="; b
End Sub
举一反三
- 运行下面的程序,第二行显示结果是___________。 Private Sub Form_Click() Dim A As Integer Dim i As Integer A = 5 For i = 1 To 9 Call sub1(i, A) Print i, A Next i End Sub Private Sub sub1(x As Integer, y As Integer) Static N As Integer Dim I As Integer For I = 3 To 1 Step -1 N = N + x x = x + 2 Next I y = y + N End Sub
- 编写如下程序: Private Sub Command1_Click() Dim x As Integer, y As Integer x = 1: y = 1 Do y = x * y If y > 10 Then Print x, y Exit Do Else x = x + 3 End If Loop While x <= 10 End Sub 运行程序,输出结果为______
- Sub s1(ByVal x As Integer, ByVal y As Integer) Dim t As Integer t = x: x = y: y = t End Sub Sub s2(x As Integer, y As Integer) Dim t As Integer t = x: x = y: y = t End Sub 则以下说法中正确的是( )。
- 下列程序的输出结果是:x = 1 y = 2 def swap(a, b): t = a a = b b = t print a, b swap(x, y) print x, y A: 1 21 2 B: 2 11 2 C: 1 22 1 D: 2 12 1
- 以下程序运行后的输出结果是 ______。 Sub add(x,y) x=x+y Print "x=";x;",y=";y End Sub Private Sub Command1_Click() x=1 y=1 Call add((x),(y)) Print"x="; x;",y=";y End Sub A: x=1,y=1 B: x=2,y=2 C: x=2,y=1 D: x=1,y=1 E: x=1,y=1 F: x=1,y=1 G: x=2,y=1 H: x=2,y=1