1 2 1
1 2 3 2 1
3.设在一个窗体(如图所示)中已设置了一个组合框Combo1和文本框Text 1,且有下列程序,试写出事件过程Combo1_Click的功能。
Dim str As String
Private Sub Form_Load() str = \
Combo1.AddItem \北京\Combo1.AddItem \天津\Combo1.AddItem \西安\
Combo1.AddItem \上海\Combo1.AddItem \武汉\Combo1.AddItem \广州\Combo1.AddItem \海口\Combo1.Text = \北京\
End Sub
Private Sub Combo1_Click()
str = str & Combo1.Text & \,\
Text1.Text = str
End Sub
在文本框中显示单击组合框列表项目时该项目的内容,而且以后来添加的方式在文本框中显示所有选择项目的内容。
4. 写出执行下列事件过程的输出结果。
Private Sub Form_Click()
Dim a(1 To 2, 1 To 2) As Integer
Dim i As Integer, j As Integer
For i = 1 To 2
For j = 1 To 2
a(i, j) = (2 * i - 1) * 4 + j
Next j
Next i
For i = 1 To 2
Print a(i, 3 - i), a(3 - i, i)
Next i
End Sub
6 13
13 6
5.写出执行下列事件过程的输出结果。
Private Sub Command1_Click()
Dim a As Integer, b As Integer
a = 3: b = 2
Call f(8, a)
Print \
Call f(a, b)
Print \
End Sub
Private Sub f(ByVal x As Integer, y As Integer)
x = x + 1
y = y - 1
End Sub
a=2 b=2
a=2 b=1
6.若有如下窗体模块:
Dim a As Integer
Private Sub test()
Dim b As Integer
a = a + 1: b = b + 1
Print \
End Sub
Private Sub Command1_Click()
a = 2: b = 3
Call test
Call test
End Sub
写出当程序启动并单击命令按钮后,在窗体中显示的结果。
Sub: 3 1
Sub: 4 1
四、程序填空题 (每空2分,共22分)
1. 下面事件过程的功能是:输入某个学生某门课程的百分制成绩,并根据成绩输出评语,若0≤成绩<60 时,评语为“差”;若60≤成绩<70时,评语为“通过”;若70≤成绩<80时,评语为“中等”;若80≤成绩<90时,评语为“良好”;若90≤成绩≤100时,评语为“优秀”,在横线上填上适当内容。
Private Sub Command1_Click()
Dim s!
s = InputBox(\请输入学生的成绩:\
If 0<=s And s<=100 Then
Select Case (1) s
Case Is >= 90
Print \优秀\
Case Is >= 80
Print \良好\