题型:综合题 题类:常考题 难易度:困难
浙江省嘉兴市2021届高三上学期信息技术9月教学测试
现需要设计一程序,在窗体加载时,读取数据库中学生的订餐情况,以班级+姓名+订餐情况输出至列表框List1中,在文本框Text1中输人班级,单击命令按钮Command1统计该班级的订餐情况,程序运行如图b所示。
Dim xm(1 To 1000) As String, bj(1 To 1000) As Integer
Dim tc1(1 To 1000) As String, tc2(1 To 1000) As String
Dim n As Integer '学生总人数
Private Sub Form_ Load( )
'从数据库中按班级、学号有序地读取学生的姓名、班级、中午套餐、晚上套餐,
'依次存人xm、bj、tc1、tc2数组中,在List1中显示,总人数存人n中,代码略
End Sub
Private Sub Command1_ Click( )
Dim k As Integer, i As Integer, j As Integer, m As Integer
Dim zc(1 To 4) As Integer, wc(1 To 4) As Integer '用于统计套餐数量
k = Val(Text1.Text)
For i=1 To 4 '为数组赋初始值
zc(i)=0:wc(i)=0
Next i
i=1:j=n '查找班级里第一-位同学的序号
Do While i<=j
m=(i+j)\2
If Then i=m+1 Else j= m-1
Loop
For i=j+1 To n
If bj(i) = k Then
'改错
wc(fx(tc2(i)))= wc(fx(tc2(i))) + 1
End If
If Then Exit For
Next i
's为班级订餐统计信息,代码略
List2.AddItem s
End Sub
Function fx(a As String) As Integer '将套餐字母转换为数字序号
End Function
试题篮