题型:综合题 题类:模拟题 难易度:困难
浙江省杭州市2016年信息技术高考模拟卷十一
VB应用程序界面如上图所示,在文本框text1中输入查询的日期(以月日形式,如0623),单击“查询”按钮,在列表框中显示所有这个日子出生的员工姓名(按姓名排序),并在Label3处显示员工数量,如果人数为0,则在列表框中显示“本天没有员工生日”。
解决此问题的VB程序如下,阅读程序并完成后面的问题。
‘定义存放员工姓名的数组na
Private Sub CmsqClick()
Dim n As Integer , i As Integer , j As Integer
Dim t1 As String
‘连接数据库获取数据
Dim cn As new connection
Dim rs As new recordest
Dim str1 As String , str2 As String
str1 =”driver=Microsoft access driver(*.mdb)”;dbq=”&app.path”&”员工信息.mdb”
cn.open str1
str2 = “select * form members where 生日 =’“ + text1.text + ”’”
rs.open str2 , cn.adOpenDynamic ,adLockOptimistic
n = 0
Do While Not Rs.EOF
n = n + 1
na(i) = rs.Fields(“姓名”).value
rs.MoveNext
Loop
rs.close
cn.close
‘按姓名排序
If n = 0 Then
List1.AddItem “本天没有员工生日”
Else
For i = 1 to n-1
For j = 1 to n+1 Step -1
If na(j) < na(j-1) Then
t1 = na(j) : ① : na(j-1) = t1
End If
Next j
Next i
For i = 1 to n
List1.AddItem ②
Next i
Label3.Caption = “这天共” + Str(n) + “位员工生日”
End If
End Sub
试题篮