'窗体添加一个List1 四个Text1.2.3.4. 一个Timer1属性150
Private Sub Form_Load()
If Dir("C:\Documents and Settings\Administrator\桌面\112.txt") <> "" Then
Dim aa As String
Open ("C:\Documents and Settings\Administrator\桌面\112.txt") For Input As #1
Do While Not EOF(1)
Line Input #1, aa
List1.AddItem aa
Loop
Close #1
End If
'全部数量
Text4 = List1.ListCount
End Sub
Private Sub List1_Click()
Dim fj() As String
If InStr(1, List1.List(List1.ListIndex), "----") > 0 Then
fj = Split(List1.List(List1.ListIndex), "----")
'按---分成前后两段
Text1.Text = fj(0)
Text2.Text = fj(1)
Else
Text1.Text = ""
Text2.Text = ""
End If
Text3.Text = List1.ListIndex + 1
End Sub
Private Sub Timer1_Timer()
Static CI As Long
'定义静态变量
Dim fj() As String
If CI > List1.ListCount Then CI = 0
'超出范围返回第一个
If InStr(1, List1.List(CI), "----") > 0 Then
'是有效数据
fj = Split(List1.List(CI), "----")
'按---分成前后两段
Text1.Text = fj(0)
Text2.Text = fj(1)
List1.ListIndex = CI
Else
Text1.Text = ""
Text2.Text = ""
End If
CI = CI + 1
'Command2.Caption = CI '下一次显示下一个。
If Text3.Text = Text4.Text Then
List1.ListIndex = 0
Timer1.Enabled = False
End If
'感谢版主:风吹过b
'代码完美付出 我相信以后会有人用到的!