Option Explicit
Option Base 1
Dim Xm$(), n&
' 文本框:Text1
' 两个按钮:开始、停止
' 姓名在【名字.TXT】文件中,每人一行
Private Sub 装入数组()
Dim CC$, i&
' 测试人数
n = 0
Open "名字.TXT" For Input As #1
Do While Not (EOF(1))
Line Input #1, CC
n = n + 1
Loop
Close #1
' 装入数组
ReDim Xm(n)
Open "名字.TXT" For Input As #1
For i = 1 To n
Line Input #1, CC
Xm(i) = Trim(CC)
Next i
Close #1
End Sub
Private Sub Timer1_Timer()
Dim m&
Randomize
m = 1 + Int(n * Rnd)
Text1.Text = Xm(m)
End Sub
Private Sub Form_Load()
Call 装入数组
End Sub
Private Sub 开始_Click()
Timer1.Interval = 15
End Sub
Private Sub 停止_Click()
Timer1.Interval = 0
End Sub