试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:困难

浙江省诸暨市牌头中学2018届高三上学期信息技术期中考试试题

【加试题】小李编写一个统计学生选考科目的VB程序,算法的基本思想是:检查每位学生选课组合的编码是否有效,对有效选择结果进行科目统计,根据各科次占有效人数的百分率求出各科排名。程序运行时,单击“显示”按钮Commmad1,学生选课数据显示在列表框list1中,各科编号及对应科目名称显示列表框list2中,单击“统计”按钮Commmad2,选课结果按各科百分率由高到低显示在列表框list3中,程序运行结果如图所示。

实现上述功能的VB程序如下,请回答下列问题:

(1)、学生选课的编码数据存储在数据表中,其字段名为
(2)、请在划线处填入合适的代码。

Dim ach(1 To 500) As String     '存储各学生选课编码

Dim bno(1 To 10) As Integer     '存储各科目编号

Dim bname(1 To 10) As String    '存储各科目名称

Dim bnum(1 To 10) As Integer    '存储各科目被选次数

Dim bmc(1 To 10) As Integer     '存储各科目被选的名次

Dim n As Integer, num As Integer

Private Sub Command1_Click()

Dim i As Integer, km As String

km = "物理化学生物政治历史地理技术"

Dim cn As New ADODB.Connection, rs As New ADODB.Recordset, sql As String

cn.Open "provider=Microsoft.Jet.oledb.4.0;Data Source=" + App.Path + "\students.mdb"

rs.Open "select * from choose", cn

Do While Not rs.EOF

n = n + 1 : ach(n) = rs.Fields("subject") : rs.MoveNext

Loop

rs.Close

cn.Close

Set rs = Nothing

Set cn = Nothing

For i = 1 To 7

bno(i) = i

bname(i) = Mid(km, (i - 1) * 2 + 1, 2)

   List2.AddItem Str(bno(i)) + "---" + bname(i)

Next i

End Sub

Private Sub Command2_Click()

Dim i As Integer, j As Integer, k As Integer

Dim c As String, per As Integer

For i = 1 To n

If check(ach(i)) = True Then

For j = 1 To 3

c = Mid(ach(i), j, 1)

bnum(Val(c)) =      

  Next j

num = num + 1

End If

Next i

i = 1

Do While i <= 7'该循环得到各学科被选人数的名次

bmc(i) = 1

For j = 1 To 7

If bnum(j) >bnum(i) Then      

Next j

i = i + 1

Loop

For i = 1 To 7

For j = 1 To 7

If        Then

per = Int(bnum(j) * 100 / num * 100) / 100

List3.AddItem Str(bno(j)) + "---" + bname(j) + "---" + Str(per) + "%"

End If

Next j

Next i

End Sub

Function check(s As String) As Boolean

   '代码略! 若学生选科代码有效,函数返回True,否则返回False

End Function

返回首页

试题篮