编写VB程序,实现上述功能。运行程序时,先读取每个选择题的题号、得分率和考点,显示在列表框List 1中。在文本框Text 1中输入得分率最低的前m项值,单击“统计”按钮,按照得分率从小到大升序排序,并在列表框List 2中输出得分率最低前m项的题号、得分率及考点。程序运行界面如图所示。
请回答下列问题:
Dim n As Integer
Dim th(0 To 100)As Integer,df(0 To 100)As Single,kd(1 To 100)As String
Private Sub Form_Load( )
‘读取题号、得分率和考点分别存入数组th、df和kd数组,在列表框List 1中显示,代码略
‘选择题的个数存入变量n,代码略
End Sub
Function dq(x As String,k As Integer)As String
‘固定数据的位数
dq= X
Do While
dq=dq+""
Loop
End Function
Private Sub Select _Click( )
Dim m As Integer,i As Integer,j As Integer,p As Integer,t As Integer,mm As Integer
List 2.Clear
m=Val(Text1.Text)
i=1
Do While i<=n-1
p=i
For j=i+1 To n
If Then p= j
Next j
If p<i Then
t=th(i):th(i)= th(p):th(p)= t
End If
If Then Exit Do
i=i+1
Loop
For i=1 To m
List 2.AddItem dq(Str(th(i)),6)+ dq(Str(df(th(i))),8)+ dq(kd(th(i)),12)
Next i
End Sub