某次考试的流程为先笔试再面试,笔试成绩达到面试资格线的可以入围参加面试。入围面试的资格线根据计划录取人数的200%划定,即如果考试最终录取x人,则第2*x名选手的笔试分数为面试资格的分数线(该分若有同分者可一同参与面试)。现在编写VB程序功能如下:自动读取数据库中考生考号和笔试成绩,依次存储在数组kh(i)、cj(i)中,并显示在List1列表框中。单击“入围划线”按钮Command1,面试分数线显示在文本框Text2中,入围面试最终人数显示在Text3中,进入面试的考生的考号和笔试成绩显示在List2列表框中,如果成绩相同,则按考号由小到大的顺序显示。程序界面如图所示。
Dim kh(1 to 500) As string,cj(1 to 500) As Integer Dim n As Integer ‘参加考试总人数
Private Sub Form_Load()
Dim conn as new ADODB.connection:Dim rs As New ADODB.Recordset
conn.ConnectionString=“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=”
+App.Path+”\BSCJ.accdb”
conn.Open
set rs.activeconnection=conn
rs.Open“select*FROM scoreinfo”
‘本过程其他代码略 End Sub
Private Sub Command1_Click()
Dim m As Integer,i As Integer,j As Integer
Dim t1 As Integer,t2 As String,flag As Boolean For i = 1 To n-1 ‘排序
For j = ① If cj(i)<cj(j) Then
t1 = cj(i):cj(i) = cj(j):cj(j) = t1
t2 = kh(i):kh(i) = kh(j):kh(j) = t2 Elseif cj(i) = cj(j) And kh(i) > kh(j) Then
t2 = kh(i):kh(i) = kh(j):kh(j) = t2
End If Next j
Next i
m = ②
If m <= n Then ‘统计进入面试人数
i = m
flag = False
Do While ③ If cj(i) = cj(i+1) Then
i = i+1 Else
flag = True End If
Loop
Text2.text = Str(cj(m)) Text3.text = Str(i)
For j = 1 To i
List2.AddItem kh(j) + “ ” + Str(cj(i)) Next j
Else
Text2.Text=”面试人数超过总人数了” End If
End Sub