新手上路,各位高手帮忙看看这个代码,提示缺少数组。谢谢指教
Private Sub Form_Load()Dim a() As String
Dim i As String
i = 0
'定义名单跳转的时间为10s
Timer1.Interval = 10
Timer1.Enabled = False
Command1.Caption = "开始"
Label1.Alignment = 2 '字体居中
Label1.Font = "微软雅黑" '字体为 微软雅黑
Label1.FontSize = 15 '字体的大小
'读取名单,注意名单必须放在D盘的txt内
Open "D:\1.txt" For Input As #1
Do Until EOF(1)
i = i + 1
ReDim Preserve a(1 To i) As String
Line Input #1, a(i) '按行读取名单,所有的名单必须一行一个
Loop
End Sub
Private Sub Timer1_Timer()
Dim a As String
Dim j As Integer
Randomize
'i 为名单的人数,Rnd为0-1之间数,不包括0,1
j = Int(i * Rnd + 1)
Label1.Caption = a(j)
End Sub