Dim zh(1 To 16) As String,zrs As Integer
Dim xk(1 To 1000) As String '存放同学的选课科目组合,已知学生人数少于1000人
Dim zh2(1 To 35) As String '存放35种选课科目组合
Dim rstj(1 To 35) As Integer '存放各种选课组合选课人数
Private Sub Form_ Load( )
'本过程从数据库中读取学生的选课情况数据,存放在数组xk中,学生的总人数存放在变量zrs。
'代码略
End Sub
Private Sub Command1_ Click()
Dim iAs Integer, j As Integer, m As Integer, n As Integer, k As Integer
Dim km(1 To 7) As String
List1.Clear
List1.AddItem "序号"+ "" + "组合名称"
km(1) = "物": km(2) = "化": km(3)= "生": km(4)= "政"
km(5) = "史": km(6) = "地": km(7)= "技"
m= 1
For i= 1 To 5
For k=i+ 1 To 6
zh(m) = km(i) + km(k)
m=m+1
Next k
Next i
j=3:n= 1:y=j
For i= 1 To m
For k=y To 7
zh2(n)=
If n<= 9 Then
List1.AddItemn&""&" " & zh2(n)
Else
List1.AddItemn&" " & zh2(n)
End If
n=n+ 1
Next k
y=y+ 1
If y= 8 Then
j= : y=j
End If
Next i
End Sub
Private Sub Command2_ Click()
Dim i As Integer
List2.Clear
List2.Addltem "组合名称" +""+ "选课人数”
For i= 1 To 35
rstj(i)=
List2.AddItem zh2(i) +"" + Str(rsij(0)
Next i
End Sub
Function tj(zhme As String) As Integer '统计某种选课组合的选课人数
Dim i As Integer, rs As Integer
rs= 0
For i= 1 To zrs
If zhmc = xk(i) Then
rs=rs+ 1
End If
Next i
tj=rs
End Function