计算机等级 > 二级考试 > Visual Basic > VB模拟试题 > 文章内容

全国计算机二级考试VB程序设计复习试题答案(19)

2016-6-25编辑:ljnbset

1.       下面关于图片框和图像框的说法中正确的是(   )

(A)      图像框和图片框均可通过Print方法显示文本

(B)      在图像框里只能显示图片,不能包含其它控件,而图片框可以包含控件

(C)     图像框比图片框占用的内存多、运行速度慢

(D)     在图片框和图像框中显示的图片均可放大和缩小

2.       在窗体上画两个名称为Text1和Text2的文本框和一个名称为Command1的命令按钮,然后编写如下事件过程:

            Private Sub Command1_Click( )

                Dim x As Integer, n As Integer

                x = 1

                n = 0

                Do While x < 20

                   x = x * 3

                   n = n + 1

                Loop

                Text1.Text = Str(x)

                Text2.Text = Str(n)

            End Sub

  程序运行后,单击命令按钮,在两个文本框中显示的值分别是(   )

(A)15和1           B273        (C)195和3             (D)600和4

3.       在窗体上画一个名称为Text1的文本框和一个名称为Command1的命令按钮,然后编写如下事件过程:

Private Sub Command1_Click( )

  Dim i As Integer, n As Integer

  For i = 0 To 50

i = i + 3

n = n + 1

If i > 10 Then Exit For

                Next

                Text1.Text = Str(n)

            End Sub

  程序运行后,单击命令按钮,在文本框中显示的值是(   )

(A)2                    B3                 (C)4                        (D)5

4.       在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程:

            Private Sub Comman1_Click( )

                x = 0

                n = InputBox(“ “)

                For i = 1 To n

                   For j = 1 To i

                       x = x + 1

                   Next j

                Next i

                Print x

            End Sub

程序运行后,单击命令按钮,如果输入3,则在窗体上显示的内容是(   )

(A)3                    (B)4                 (C)5                        D6

5.       在窗体上画一个命令按钮,然后编写如下事件过程:

            Private Sub Command1_Click( )

                For i = 1 To 4

                   x = 4

                   For j = 1 To 3

                       x = 3

                       For k = 1 To 2

                          x = x + 6

                       Next k

                   Next j

                Next i

                Print x

            End Sub

程序运行后,单击命令按钮,输出结果是(   )

(A)7                    B15               (C)157                    (D)538

6.       在窗体上画一个命令按钮,然后编写如下事件过程:

            Private Sub Command_Click( )

                x = 0

                Do Until x = -1

                   a = InputBox(“请输入A的值:”)

                   a = Val(a)

                   b = InputBox(“请输入B的值:”)

                   b = Val(b)

                   x = InputBox(“请输入x的值:”)

                   x = Val(x)

                   a = a + b + x

                Loop

                Print a

            End Sub

程序运行后,单击命令,依次在输入对话框中输入5、4、3、2、1、-1,则输出的结果为(   )

A2                    (B)3                        (C)14                      (D)15

7.       在窗体上画一个名称为Command1的命令按钮和一个名称为Label1的标签,然后编写如下事件过程:

Private Sub Command1_Click( )

  s = 0

  For i =1 To 15

x = 2 * i -1

If x Mod 3 =0 Then s = s + 1

                Next i

                Label1.Caption = s

            End Sub

程序运行后,单击命令按钮,则标签中显示的内容是(   )

(A)1                    B5                        (C)27                      (D)45

8.       在窗体上画一个名称为Command1的命令按钮和两个名称分别为Text1、Text2的文本框,然后编写如下事件过程:

Private Sub Command1_Click( )

  a = Text1.Text

  Select Case n

    Case 1 To 20

x = 10

Case 2,4,6

  x = 20

Case Is < 10

  x = 30

Case 10

  x = 40

End Select

Text2.Text = x

            End Sub

程序运行后,如果在文本框Text1中输入10,然后单击命令按钮,则在Text2中显示的内容是(   )

A10                  (B)20               (C)30                      (D)40

9.       有如下程序:

            a = 10

            b = 4

            For j = 1 To 20 Step -2

                a = a + 5

                b = b + 4

            Next j

            Print a;b

运行后,输出的结果是(   )

A10 4             (B)60 24              (C)110 44            (D)55 40

10.   设有如下程序:

            Private Sub Command1_Click( )

                Dim sum As Double, x As Double

                sum = 0

                n = 0

                For i = 1 To 5

                   x = n / i

                   n = n + 1

                   sum = sum + x

                Next

            End Sub

该程序通过For循环计算一个表达式的值,这个表达式是(   )

(A)1 + 1 /2 + 3/ 4 + 4 / 5                        (B)1 + 1 /2 + 2 / 3 + 3 / 4

(C)1 / 2 + 2 / 3 + 3 / 4 + 4 / 5                 (D)1 + 1 / 2 + 1 / 3 + 1 / 4 + 1 / 5

全国计算机二级考试VB程序设计复习试题答案(18)

热点推荐

登录注册
触屏版电脑版网站地图