17、【
单选题
】 在窗体上画一个文本框,然后编写如下事件过程:
Private Sub Form_Click()
x = InputBox("请输入一个整数")
Print x + Text1.Text
End Sub
程序运行时,在文本框中输入456,然后单击窗体,在输入对话框中输入123,单击“确定”按钮后,在窗体上显示的内容为( )。
[2分]
、
123
、
456
、
479
、
123456
答案:
18、【
单选题
】 在窗体上画一个文本框和一个计时器控件,名称分别为Text1和Timer1,在属性窗口中把计时器的Interval属性设置为1000,Enabled属性设置为False。程序运行后,如果单击命令按钮,则每隔一秒钟在文本框中显示一次当前的时间。以下是实现上述操作的程序:
Private Sub Command1_Click()
Timer1.( )
End Sub
Private Sub Timer1_Timer()
Text1.Text = Time
End Sub
在下划线处应填入的内容是( )。
[2分]
、
Private Sub List1_Click()
Label1.Caption = List1.ListIndex
End Sub
、
Private Sub List1_Click()
Label1.Name=List1.ListIndex
End Sub
、
Private Sub List1_Click()
Label1.Name=List1.Text
End Sub
、
Private Sub List1_Click()
Label1.Caption =List1.Text
End Sub
答案:
21、【
单选题
】 在窗体上画一个命令按钮,其名称为Command1,然后编写如下事件过程:
Private Sub Command1_Click()
Dim i As Integer, x As Integer
For i = 1 To 6
If i = 1 Then x = i
If i <= 4 Then
x = x + 1
Else
x = x + 2
End If
Next i
Print x
End Sub
程序运行后,单击命令按钮,其输出结果为( )。
[2分]
、
9
、
6
、
12
、
15
答案:
22、【
单选题
】 在窗体上画一个名称为Command1命令按钮,然后编写如下事件过程:
Private Sub Command1_Click()
c = “ABCD”
For n= 1 To 4
Print ( )
Next
End Sub
程序运行后,单击命令按钮,要求在窗体上显示如下内容
D
CD
BCD
ABCD
则在( )处填入的内容为。
[2分]
、
Left(c,n)
、
Right(c,n)
、
Mid(c,n,1)
、
Mid(c,n,n)
答案:
23、【
单选题
】 执行以下程序段
Dim i As Integer, x As Integer
x = 0
For i = 20 To 1 Step -2
x = x + i \ 5
Next
Print x
后,x的值为( )。
[2分]
26、【
单选题
】 把窗体的KeyPreview属性设置为True,然后编写如下事件过程
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim ch As String
ch = Chr(KeyAscii)
KeyAscii = Asc(UCase(ch))
Print Chr(KeyAscii + 2)
End Sub
程序运行后,按键盘上的“A”键,则在窗体上显示的内容是( )。
[2分]
、
A
、
B
、
C
、
D
答案:
27、【
单选题
】 在窗体上画一个命令按钮和一个文本框,名称分别为Command1和Text1,然后编写如下程序:
Private Sub Command1_Click()
a=InputBox(“请输入日期(1~31)”)
t=”旅游景点:” _
& IIf ( a > 0 And a <= 10,”长城”,””) _
& IIf ( a >10 And a <= 20,”故宫”,””) _
& IIf ( a > 20 And a <= 31,”颐和园”,””)
Text1.Text = t
End Sub
程序运行后,如果从键盘上输入16,则在文本框显示的内容是( )。
[2分]
、
旅游景点:长城故宫
、
旅游景点:长城颐和园
、
旅游景点:颐和园
、
旅游景点:故宫
答案:
28、【
单选题
】 在窗体上画一个名称为Label1的标签,然后编写如下事件过程:
Private Sub Form_Click()
Dim arr(10, 10) As Integer
Dim i As Integer, j As Integer
For i = 2 To 4
For j = 2 To 4
arr(i, j) = i * j
Next j
Next i
Label1.Caption = Str(arr(2, 2) + arr(3, 3))
End Sub
程序运行后,单击窗体,在标签中显示的内容是( )。
[2分]
、
12
、
13
、
14
、
15
答案:
29、【
单选题
】 在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程:
Private Function fun(ByVal m As Integer)
If m Mod 2 = 0 Then
fun = 2
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
程序运行后,单击命令按钮,在窗体上显示的是( )。
[2分]
、
6
、
7
、
8
、
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
程序运行后,单击窗体,输入结果为( )。
[2分]
、
21
、
13
、
8
、
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
程序运行后,如果单击命令按钮,则在窗体上输出的内容为( )。
[2分]
、
10
、
16
、
12
、
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,则输出结果是( )。
[2分]
、
12
、
11
、
10
、
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(
End If
Next i
Close
End Sub
程序运行后,单击命令按钮,文件outf.txt中的内容是( )。
[2分]
、
MVBP
、
mvbp
、
M
V
B
P
、
m
v
b
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,则程序的执行结果为( )。
[2分]
、
输出0
、
输出25
、
输出45
、
无任何输出
答案:
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
程序运行后,单击命令按钮,则在文本框中显示的内容是( )。
[2分]