窗体上有标签(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将分别显示
举一反三
- 在窗体上添加一个命令按钮Command1和3个标签Label1、Label2、Label3,然后编写如下代码。 Private x As Integer Private Sub Command1_Click() Static y As Integer Dim z As Integer n = 10 z = n + z y = y + z x = x + z Label1.Caption = x Label2.Caption = y Label3.Caption = z End Sub 运行程序,连续 3 次单击命令按钮后,则 3 个标签中显示的内容分别是( )。
- 设窗体上有一个Command1命令按钮,还有以下程序代码: Private Sub Command1_Click() Static x As Integer x=x+1 Call proc(x) Print x, End Sub Private Sub proc(a As Integer) Static x As Integer x=x+a:a=x End Sub 程序运行后,3次单击命令按钮,则产生的输出是 A: 1 2 3 B: 1 3 5 C: 1 3 7 D: 2 4 6
- 运行下面的程序,第二行显示结果是___________。 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
- 设有如下通用过程,在窗体上画一个名称为command1的命令按钮,然后编写如下事件过程: private sub command1_click() dim x as integer x=10 y=5 y=f(x) print x;y end sub public function f (x as integer) dim y as integer x=20 y=2 f=x*y end function 程序运行后,如果单击命令按钮,则在窗体上显示的内容是()
- 编写如下程序: 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 运行程序,输出结果为______