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 则以下说法中正确的是( )。
举一反三
- 假定有以下两个过程: Sub S1(ByVal x As Integer, ByVal y As Integer) Dim t As Integer t=K x=y y=t End Sub Sub S2(x As Integer, y As Integer) Dim t As Integer t=K x=y y=t End Sub 则以下说法中正确的是 ( ) A.用过程S1可以实现交换两个变量值的操作,S2不能实现 B.用过程S2可以实现交换两个变量值的操作,S1不能实现 C.用过程S1和S2都可以实现交换两个变量值的操作 D.用过程S1和S2都不能实现交换两个变量值的操作
- 本程序的功能为单击窗体,分别调用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
- 窗体上有标签(Label1、Label2)和命令按钮(Command1),编写如下事件过程: Private x As Integer: Private Sub Command1_Click(): Dim x As Integer, y As Integer: x = 5: y = 3: proc x, y: Label1.Caption = x: Label2.Caption = y: End Sub: Private Sub proc(ByVal a As Integer, b As Integer): x = a + b: b = b * b: End Sub:运行后,单击按钮,Label1和Label2将分别显示
- 运行下面的程序,第二行显示结果是___________。 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 Command33_Click() Dim x As Integer, y As Integer x = 1: y = 0 Do Until y <= 25 y = y + x * x x = x + 1 Loop MsgBox "x=" & x & ", y=" & y End Sub