实现考场分配功能的VB程序如下,请在划线处填入合适的代码。
Dim
n As Integer, y As String
Dim
cla(1 To 20)As Integer, num(I To 20)As Integer
Dim
room as Integer ‘存储考场号
Dim
seat as Integer ‘存储座位号
Function
fm(k As Integer) As String
‘返回整数k(l≤k≤99)对应的数字字符串,不足两位左侧补“0”,代码略
End
function
Private
Sub Command 1_ Click( )
‘从Text1中读取入学年份存入变量y,从数据库中读取该人学年份的班级数据
‘将班级个数存人变量n(1<n≤20),各班班号和人数分别存人数组cla和num
‘各班班号均大于0,各班人数均未超过总人数的一半
‘将数组cla和num按班级人数降序排列后,显示在List l中,代码略
End
Sub
Private
Sub Command 2_ Click( )
Dim i
As Integer, t As Integer, s As Integer
Dim choice
As Integer, m As Integer, f As Boolean
room=1
: seat=1 : choice=0
Do While
f = True
If cla
(1) <> choice Then m= 1 Else m = 2
choice
= cla(m)
‘在列表框List2中显示准考证号、考场号、座位号
List 2.
Addltem y+fm(cla(m))+fm(num(m))+" "+fm(room)+" "+fm(seat)
seat = seat+ 1
If seat
> 30 Then
seat = 1
End If
num(m)= num(m)-1
For i=To n-1 ‘维护班级降序序列(按未分配人数)
If num(i)< num(i + 1)Then
t=num(i) : num(i)=num(i+1) : num(i+1)=t
s = cla(i) : cla(i)= cla(i + 1) : cla(i+1)=s
Else
Exit For ‘ExitFor表示退出循环
End If
Next i
IfThen f = False
Loop
End Sub