计算机等级 百分网手机站

9月全国计算机vb二级考试题库(3)

时间:2017-08-29 14:32:52 计算机等级 我要投稿

2016年9月全国计算机vb二级考试题库

  Else

  fun = 1

  End If

  End Function

  Private Sub Command1_Click()

  Dim i As Integer, s As Integer

  s = 0

  For i = 1 To 5

  s = s + fun(i)

  Next

  Print s

  End Sub

  程序运行后,单击命令按钮,在窗体上显示的是______。

  A)6 B)7 C)8 D)9

  (30)阅读程序:

  Option Base 1

  Dim arr() As Integer

  Private Sub Form_Click()

  Dim i As Integer, j As Integer

  ReDim arr(3, 2)

  For i = 1 To 3

  For j = 1 To 2

  arr(i, j) = i * 2 + j

  Next j

  Next i

  ReDim Preserve arr(3, 4)

  For j = 3 To 4

  arr(3, j) = j + 9

  Next j

  Print arr(3, 2) + arr(3, 4)

  End Sub

  程序运行后,单击窗体,输入结果为______。

  A)21 B)13 C)8 D)25

  (31)在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:

  Option Base 1

  Private Sub Command1_Click()

  Dim c As Integer, d As Integer

  d = 0

  c = 6

  x = Array(2, 4, 6, 8, 10, 12)

  For i = 1 To 6

  If x(i) > c Then

  d = d + x(i)

  c = x(i)

  Else

  d = d - c

  End If

  Next

  Print d

  End Sub

  程序运行后,如果单击命令按钮,则在窗体上输出的内容为______。

  A) 10 B) 16 C) 12 D) 20

  (32)设有如下程序:

  Private Sub Command1_Click()

  Dim c As Integer, d As Integer

  c = 4

  d = InputBox("请输入一个整数")

  Do While d > 0

  If d > c Then

  c = c + 1

  End If

  d = InputBox("请输入一个整数")

  Loop

  Print c + d

  End Sub

  程序运行后,单击命令按钮,如果在输入对话框中依次输入1、2、3、4、5、6、7、8、9、0,则输出结果是______。

  A)12 B)11 C)10 D)9

  (33)在窗体上画一个名称为Command1的命令按钮和一个名称为Text1的文本框,在文本框中输入以下字符串:Microsoft Visual Basic Programming

  然后编写如下事件过程:

  Private Sub Command1_Click()

  Open "d:\temp\outf.txt" For Output As #1

  For i = 1 To Len(Text1.Text)

  c = Mid(Text1.Text, i, 1)

  If c >= "A" And c <= "Z" Then

  Print #1, LCase(c)

  End If

  Next i

  Close

  End Sub

  程序运行后,单击命令按钮,文件outf.txt中的内容是______。

  A)MVBP B)mvbp C)M D)m

  V v

  B b

  P p

  (34)在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:

  Dim SW As Boolean

  Function func(X As Integer) As Integer

  If X < 20 Then

  Y = X

  Else

  Y = 20 + X

  End If

  func = Y

  End Function

  Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

  SW = False

  End Sub

  Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

  SW = True

  End Sub

  Private Sub Command1_Click()

  Dim intNum As Integer

  intNum = InputBox("")

  If SW Then

  Print func(intNum)

  End If

  End Sub

  程序运行后,单击命令按钮,将显示一个输入对话框,如果在输入对话框中输入25,则程序的执行结果为______。

  A)输出0 B)输出25 C)输出45 D)无任何输出

  (35)设有如下通用过程:

  Public Sub Fun(a() As Integer, x As Integer)

  For i = 1 To 5

  x = x + a(i)

  Next

  End Sub

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

  Private Sub Command1_Click()

  Dim arr(5) As Integer, n As Integer

  For i = 1 To 5

  arr(i) = i + i

  Next

  Fun arr, n

  Text1.Text = Str(n)

  End Sub

  程序运行后,单击命令按钮,则在文本框中显示的内容是______。

  A)30 B)25 C)20 D)15

  【参考答案】

  选择题:

  1---5 DBDCA

  6---10 CBDDC

  11--15 ABBCD

  16--20 CDABD

  21--25 ABCDB

  26--30 CDBBA

  31--35 CDDDA

  二、填空题(每空2分,共30分)

  请将每空的正确答案写在答题卡【1】~【15】序号的横线上,答在试卷上不得分。