如何逐行运行LIST中内容,譬如LIST第一行为ABC123(每一行都没有规律),过5秒,此过程为一次;再运行一个list中下一行,譬如DEF456.........以此类推,到10000次结束。
最好有注释。看的清楚
什么叫逐行运行LIST中内容,能解释的详细点吗?
是不是将LIST的内容每隔5秒显示到文本框中?
是的 将LIST的内容每隔5秒显示到文本框中
追答'须在在窗体上放置Command1控件、Text1控件和Timer1控件
Dim step As Integer
Private Sub Command1_Click()
Dim str As String, i As Integer, j As Integer
List1.Clear
Open "test.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, str
str = UCase(Trim(str))
For i = 0 To List1.ListCount - 1
DoEvents
If List1.List(i) = str Then Exit For
Next
If str "" And j = List1.ListCount Then List1.AddItem str
Loop
Close #1
Timer1.Enabled '启动定时器’
End Sub
Private Sub Form_Load()
Text1.Text = "" '初始化text1控件
step = 0 '初始化list1控件指向第0行
Timer1.Interval = 5000 '设置定时器计时间隔为5秒
Timer1.Enabled = False '关闭定时器
End Sub
Private Sub Timer1_Timer()
If step < List1.ListCount Then
Text1.Text = Text1.Text & List1.List(step) & vbCrLf
step = step + 1
Else
Timer1.Enabled = False
End If
End Sub