实现上述功能的VB程序如下,请回答下列问题:
Dim a(1 To 100) As String '数组大小满足处理要求,学生学号
Dim b(1 To 100) As String '数组大小满足处理要求,学生姓名
Dim i As Integer '学生总数
Dim j As Integer
Dim dd(1 To 100) As Integer
Private Sub Form_Load()
‘从数据库读取全班同学的相关信息,存储在数组a、数组b和变量i中
Dim n As Integer
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\1718.accdb"
conn.Open
Set rs.ActiveConnection = conn
strSQL = "SELECT * FROM stuinfo"
rs.Open strSQL
'本过程的其他语句略
End Sub
Private Sub Command1_Click()
Dim ShuruNum As Integer, k As Integer, y As Integer,n As Integer
Randomize
ShuruNum = Val(Text1.Text)
Label4.Caption = ""
For k = 1 To i
dd(k) = 0
Next k
If ShuruNum > 0 And ShuruNum <= i Then
j = 1
Do While j <= ShuruNum
y = Int(Rnd() * i) + 1
If Then'
dd(j) = y
j = j + 1
End If
Loop
List2.Clear
For n = 1 To ShuruNum
List2.AddItem '
Next n
Else
Label4.Caption = "错误:没有输入中奖人数或超过学生总数"
End If
End Sub
'核对重复,避免同一人再次中奖
Private Function CheckCF(p As Integer) As Boolean
Dim m As Integer,x As Boolean
x = True '初始化
For m = 1 To j
If Then '
x = False
Exit For
End If
Next m
CheckCF = x
End Function