、
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
答案:
11、【
单选题
】 在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程:
Private Sub Command1_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,则在窗体上显示的内容是
[2分]
14、【
单选题
】 在窗体上画一个命令按钮,名称为Command1,然后编写如下事件过程:
Option Base 0
Private Sub Command1_Click()
Dim city As Variant
city = Array("北京", "上海", "天津", "重庆")
Print city(1)
End Sub
程序运行后,如果单击命令按钮,则在窗体上显示的内容是
[2分]
、
空白
、
错误提示
、
北京
、
上海
答案:
15、【
单选题
】 假定有以下函数过程:
Function Fun(S As String) As String
Dim s1 As String
For i = 1 To Len(S)
s1 = UCase(Mid(S, i, 1)) + s1
Next i
Fun = s1
End Function
在窗体上画一个命令按钮,然后编写如下事件过程:
Private Sub Command1_Click()
Dim Str1 As String, Str2 As String
Str1 = InputBox("请输入一个字符串")
Str2 = Fun(Str1)
Print Str2
End Sub
程序运行后,单击命令按钮,如果在输入对话框中输入字符串"abcdefg",则单击"确定"按钮后在窗体上的输出结果为
[2分]
、
abcdefg
、
ABCDEFG
、
gfedcba
、
GFEDCBA
答案:
16、【
单选题
】 设有语句
Open "c:\Test.Dat" For Output As #1
则以下错误的叙述是
[2分]
、
该语句打开C盘根目录下一个已存在的文件Test.Dat
、
该语句在C盘根目录下建立一个名为Test.Dat的文件
、
该语句建立的文件的文件号为1
、
执行该语句后,就可以通过Print #语句向文件Test.Dat中写入信息
答案:
17、【
单选题
】 以下叙述中错误的是
[2分]
、
用Shell函数可以调用能够在Windows下运行的应用程序
、
用Shell函数可以调用可执行文件,也可以调用Visual Basic的内部函数
、
调用Shell函数的格式应为:<变量名>=Shell (……)
、
用Shell函数不能执行DOS命令
答案:
18、【
单选题
】 以下关于过程及过程参数的描述中,错误的是
[2分]
、
过程的参数可以是控件名称
、
用数组作为过程的参数时,使用的是"传地址"方式
、
只有函数过程能够将过程中处理的信息传回到调用的程序中
、
窗体可以作为过程的参数
答案:
19、【
单选题
】 在窗体上画一个名称为TxtA的文本框,然后编写如下的事件过程:
Private Sub TxtA_KeyPress(keyascii as integer)
……
End Sub
若焦点位于文本框中,则能够触发KeyPress事件的操作是
[2分]
、
单击鼠标
、
双击文本框
、
鼠标滑过文本框
、
按下键盘上的某个键
答案:
20、【
单选题
】 目录列表框的Path属性的作用是
[2分]
、
显示当前驱动器或指定驱动器上的路径
、
显示当前驱动器或指定驱动器上的某目录下的文件名
、
显示根目录下的文件名
、
只显示当前路径下的文件
答案:
21、【
单选题
】 假定有如下事件过程:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu popForm
End If
End Sub
则以下描述中错误的是
[3分]
、
该过程的功能是弹出一个菜单
、
popForm是在菜单编辑器中定义的弹出式菜单的名称
、
参数X、Y指明鼠标的当前位置
、
Button = 2表示按下的是鼠标左键
答案:
22、【
单选题
】 以下能够正确计算n!的程序是
[3分]
、
Private Sub Command1_Click()
n = 5: x = 1
Do
x = x * i
i = i + 1
Loop While i < n
Print x
End Sub
、
Private Sub Command1_Click()
n = 5: x = 1: i = 1
Do
x = x * i
i = i + 1
Loop While i < n
Print x
End Sub
、
Private Sub Command1_Click()
n = 5: x = 1: i = 1
Do
x = x * i
i = i + 1
Loop While i <= n
Print x
End Sub
、
Private Sub Command1_Click()
n = 5: x = 1: i = 1
Do
x = x * i
i = i + 1
Loop While i > n
Print x
End Sub
答案:
23、【
单选题
】 在窗体上画一个名称为Command1的命令按钮,再画两个名称分别为Label1、Label2的标签,然后编写如下程序代码:
Private X As Integer
Private Sub Command1_Click()
X = 5: Y = 3
Call proc(X, Y)
Label1.Caption = X
Label2.Caption = Y
End Sub
Private Sub proc(ByVal a As Integer, ByVal b As Integer)
X = a * a
Y = b + b
End Sub
程序运行后,单击命令按钮,则两个标签中显示的内容分别是
[3分]
、
5和3
、
25和3
、
25和6
、
5和6
答案:
24、【
单选题
】 在窗体上画一个名称为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
程序运行后,单击命令按钮,则标签中显示的内容是
[3分]
、
1
、
5
、
27
、
45
答案:
25、【
单选题
】 在窗体上画一个名称为Command1的命令按钮和三个名称分别为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分]
、
10 10 10
、
30 30 30
、
30 30 10
、
10 30 30
答案:
26、【
单选题
】 设在窗体上有一个名称为Command1的命令按钮,并有以下事件过程:
Private Sub Command1_Click()
Static b As Variant
b= Array(1,3,5,7,9)
……
End Sub
此过程的功能是把数组b中的5个数逆序存放(即排列为9,7,5,3,1)。为实现此功能,省略号处的程序段应该是
[3分]
、
For i = 0 To 5-1 \ 2
tmp = b(i)
b(i) = b(5 - i - 1)
b(5 - i - 1) = tmp
Next
、
For i = 0 To 5
tmp = b(i)
b(i) = b(5 - i - 1)
b(5 - i - 1) = tmp
Next
、
For i = 0 To 5 \ 2
tmp = b(i)
b(i) = b(5 - i - 1)
b(5 - i - 1) = tmp
Next
、
For i = 1 To 5 \ 2
tmp = b(i)
b(i) = b(5 - i - 1)
b(5 - i - 1) = tmp
Next
、
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
Label1.Caption = File1.ListCount
End Sub
、
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
Label1.Caption = File1.List
End Sub
、
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Label1.Caption = File1.ListCount
End Sub End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
Label1.Caption = File1.ListCount
End Sub
、
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Label1.Caption = File1.List
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
Label1.Caption = File1.List
End Sub
答案:
28、【
单选题
】 一个工程中包含两个名称分别为Form1、Form2的窗体,一个名称为mdlFunc的标准模块。假定在Form1、Form2和mdlFunc中分别建立了自定义过程,其定义格式为:
Form1中定义的过程:
Private Sub frmFunction1()
……
End Sub
Form2中定义的过程:
Public Sub frmFunction2()
……
End Sub
mdlFunc中定义的过程:
Public Sub mdlFunction()
……
End Sub
在调用上述过程的程序中,如果不指明窗体或模块的名称,则以下叙述中正确的是
[3分]
设有如下的类型声明
Type Person
name As String*8
major As String*20
End Type
当单击"保存"按钮时,将两个文本框中的内容写入一个随机文件Test29.dat中。设文本框中的数据已正确地赋值给Person类型的变量p。则能够正确地把数据写入文件的程序段是
[3分]
、
Open "c:\Test29.dat" For Random As #1
Put #1, 1, p
Close #1
、
Open "c:\Test29.dat" For Random As #1
Get #1, 1, p
Close #1
、
Open "c:\Test29.dat" For Random As #1 Len = Len(p)
Put #1, 1, p
Close #1
、
Open "c:\Test29.dat" For Random As #1 Len = Len(p)
Get #1, 1, p
Close #1
36、【
填空题
】 以下程序的功能是:生成20个200到300之间的随机整数,输出其中能被5整除的数并求出它们的和。请填空。
Private Sub Command1_Click()
For i = 1 To 20
x = Int(
* 200 + 100)
If
= 0 Then
Print x
S = S +
End If
Next i
Print "Sum = "; S
End Sub
[每空2分]
答案:["Rnd","x Mod 5","x"]
37、【
填空题
】 设有如下程序
Private Sub Form_Click()
Dim a As Integer, b As Integer
a = 20: b = 50
p1 a, b
p2 a, b
p3 a, b
Print "a="; a, "b="; b
End Sub
Sub p1(x As Integer, ByVal y As Integer)
x = x + 10
y = y + 20
End Sub
Sub p2(ByVal x As Integer, y As Integer)
x = x + 10
y = y + 20
End Sub
Sub p3(ByVal x As Integer, ByVal y As Integer)
x = x + 10
y = y + 20
End Sub
该程序运行后,单击窗体,则在窗体上显示的内容是:a =
和 b =
。
[每空2分]
答案:["30","70"]
38、【
填空题
】 在窗体上画一个名称为Command1的命令按钮,编写如下事件过程
Private Sub Command1_Click()
Dim a As String
a =
For i = 1 To 5
Print Space(6 - i); Mid$(a, 6 - i, 2 * i - 1)
Next i
End Sub
程序运行后,单击命令按钮,要求窗体上显示的输出结果为
5
456
34567
2345678
123456789
请填空。
[每空2分]
Private Sub Combo1_
(KeyAscii As Integer)
If KeyAscii = 13 Then
For i = 0 To Combo1.ListCount-1
If Combo1.Text =
Then
Label2.Caption = "输入项已在组合框中"
Exit Sub
End If
Next i
Label2.Caption = "已成功添加输入项"
Combo1.
Combo1.Text
End If
End Sub
[每空2分]
答案:["KeyPress","Combo1.List(i)","AddItem"]
40、【
填空题
】 设有如下程序
Private Sub search(a() As Variant, ByVal key As Variant, index%)
Dim I%
For I = LBound(a) To UBound(a)
If key = a(I) Then
index = I
Exit Sub
End If
Next I
index = -1
End Sub
Private Sub Form_Load()
Show
Dim b() As Variant
Dim n As Integer
b = Array(1, 3, 5, 7, 9, 11, 13, 15)
Call search(b, 11, n)
Print n
End Sub
程序运行后,输出结果是
。
[每空2分]