编写VB程序,实现上述功能。运行程序,在列表框List1中显示45位报名学生的报名序号和所选活动名称。单击“统计”按钮Command1,在列表框List2中显示需要调剂重报活动的学生报名序号。程序运行界面如图所示。
Const n=45
Dim a(1 To n) As String, xh(1 To n) As String
Dim c(1 To 3) As Integer
Private Sub Form_Load()
'在数据库中读取前45位学生的报名序号和所选活动项目名称,分别存入数组xh和数组a,在List1中显示。读取三项活动的限报人数,存入数组c,代码略
End Sub
Private Sub Command1_Click()
Dim b(1 To 3) As Integer, i As Integer, j As Integer, k As Integer
Dim t1 As String, t2 As String
For i=1 To n-1
For j=n To i+1 Step-1
If Then
If a(j)=″A″ Then
b(1)=j-1
Else
b(2)=
End If
t1=a(j): a(j)=a(j-1): a(j-1)=t1
t2=xh(j): xh(j)=xh(j-1): xh(j-1)=t2
End If
Next j
Next i
b(3)=n
i=1: k=1
Do While i <=n
If c(k)=0 And i <=b(k) Then
Do While i <=b(k)
a(i)=″″
i=i+1
Loop
k=k+1
ElseIf Then
k=k+1
Else
i=i+1
End If
Loop
For i=1 To n
If a(i)=″″ Then List2.AddItem xh(i)
Next i
End Sub