犬屋敷07:在vb6.0中每5秒读取List1下一条信息

来源:百度文库 编辑:高校问答 时间:2024/05/06 11:28:53
Private Sub Command3_Click()
Dim i
Dim s
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
'请在这里写出每5秒向下读取
Next
End Sub
如果用timer控件,如何用,请把代码写出来;另外public function gettime(jin as interger) 提示”用户定义类型未定义”

在模块里加如以下函数:
public function gettime(jin as interger)
ss=timer
do
doevents
tt=timer
if tt-ss>jin then exit do
loop
end function
然后这是你的程序
Private Sub Command3_Click()
Dim i
Dim s
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
gettime 5'请在这里写出每5秒向下读取
Next
End Sub

1、在界面上放一个Timer控件,把它的Interval值设置为5000(即5秒)

2、在通用部分定义一个公共变量iListIndex
Public iListIndex As Integer

3、在Form_Load中给iListIndex赋一个初始值(这部分根据你的需要在不同的位置给iListIndex赋一个初始值,可以不在Form_Load中)
Private Sub Form_Load()
iListIndex = -1
End Sub

4、在Timer1_Timer中写下如下语句
Private Sub Timer1_Timer()
iListIndex = iListIndex + 1
Text1.Text = List1.List(iListIndex)
End Sub

使用一个Timer控件及全局变量或静态变量

用timer控件