(2)
完成划线处的代码填空:
Dim classname(1 To 8000) As String ‘存储原始数据中的班级名称
Dim selectabc(1 To 8000) As String ‘存储原始数据选项的值
Dim xiangmu(1 To 8000) As String ‘存储原始数据选项的序号
Dim n As Integer
Private Sub Command2_Click() ‘从数据库读取数据,并且按班级名称排序
Dim conn As New ADODB.Connection
conn.ConnectionString = "provider=microsoft.ace.oledb.12.0;data source="&App.Path&"\pingjia.accdb"
conn.Open
Dim rs As New ADODB.Recordset
Set rs.ActiveConnection = conn
rs.Open "select * from data"
n = 0 ‘记录评价的总条数
'读取数据,并按班级排序,代码略
End Sub
Private Sub Command1_Click()
Dim cstart(1 To 50) As Integer ‘存储每个班级在数组classname中的起始位置
Dim cend(1 To 50) As Integer ‘存储每个班级在数组classname中的末尾位置
Dim k As Integer ‘存储班级数量
Dim testall(1 To 20) As Integer ‘存储每一项总选择人数,例如testall(1)里存储这评价项目1里的总人数,testc(1)里存储评价项目1里选C的人数
Dim testc(1 To 20) As Integer ‘存储每一题(项)选c的人数
‘确定每个班级的起止位置,存储到cstart数组和cend数组
cstart(1) = 1
temp = classname(1)
k = 1
For i = 1 To n
If classname(i) <> temp Then
________
k = k + 1
cstart(k) = i
temp = classname(i)
End If
Next i
cend(k) = n
For i = 1 To k ‘每个班级分别统计评价项目
________
For q = 1 To 20 ‘对testall和testc数组初始化,
testall(q) = 0
testc(q) = 0
Next q
For j = cstart(i) To cend(i) ‘对第i个班级进行统计
testall(xiangmu(j)) = testall(xiangmu(j)) + 1
If selectabc(j) = "C" Then ________
Next j
For p = 1 To 20 ‘统计完成后输出这个班级的20个项目的A+B所占百分比
s = s &""&Str(Round((testall(p) - testc(p)) / testall(p) * 100, 1))
Next p
List2.AddItem s
Next i
End Sub