(單選,填字母:A.Command 1/B.Text 1/C.List 1)。 (2)實現(xiàn)考場分配功能的VB程序如下,請在橫線處填入合適的代碼。 (3)程序中加框處代碼有錯,請改正。 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 '返回整數(shù)k(1≤k≤99)對應(yīng)的數(shù)字字符串,不足兩位左側(cè)補“0”,代碼略 End function Private Sub Command 1_ Click ( ?。?br />'從Text l中讀取入學(xué)年份存入變量y,從數(shù)據(jù)庫中讀取該入學(xué)年份的班級數(shù)據(jù), '將班級個數(shù)存入變量n(1<n≤20),各班班號和人數(shù)分別存入數(shù)組ela和num, '各班班號均大于0,各班人數(shù)均未超過總?cè)藬?shù)的一半, '將數(shù)組cla和num按班級人數(shù)降序排列后,顯示在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(ela(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'維護班級降序序列(按未分配人數(shù)) If num(i)<num(i+1)Then t=num(i):num(i)=num(i+1):num(i+1)=t s=ela(i):ela(i)=ela(i+1):ela(i+1)=s Else Exit For'ExitFor表示退出循環(huán) End If Next i If③Then f=False Loop End Sub