不建议用TIMER,可以用延时函数 private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)'延时1秒 Call Sleep(1000)
需要调用时,先把timer enable,相关数据库操作直接在Timer事件里写就可以!
如果在TIMER中写,循环读取,如何控制每次读取一个,而不是从头读啊??? 代码如何写啊??
把前面取的不同值串成串,查询加成条件就可以了 example: for .....'前面的值你的保存起来 str=str+"'"&value&"'," next str=left(str,len(str)-1) sqlstr="select top 1 value1 from table where value1 not in ("&str&")"
dim rs as new adodb.recordset private sub form_Load() ..... rs.open "select * from 表",cn,3,2 timer1.interval=2000 end subprivate sub timer1_timer() debug.print rs("字段") rs.movenext end sub
private sub timer1_timer() dim rs as new adodb.recordset rs.open "select * from 表",cn,3,2 debug.print rs("字段") rs.movenext end sub
不行啊,我在private sub timer1_timer() 里面读取数据库里面的表,速度很快,根本显示不出我要调的经纬度,从而显示在图层上啊.
比如有一个连续编号字段:Option ExplicitDim k As IntegerPrivate Sub Form_Load() Timer1.Interval = 2000 k = 1 End SubPrivate Sub Timer1_Timer() Dim s Dim cn As New ADODB. Connection Dim rs as New ADODB.Recordset
cn.open...... s = "select * from [table] where id=" & k rs.open s,cn,1,3 List1.AddItem rs.Fields(1) k = k + 1 Set rs = Nothing Set cn= Nothing End Sub
private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)'延时1秒
Call Sleep(1000)
代码如何写啊??
example:
for .....'前面的值你的保存起来
str=str+"'"&value&"',"
next
str=left(str,len(str)-1)
sqlstr="select top 1 value1 from table where value1 not in ("&str&")"
private sub form_Load()
.....
rs.open "select * from 表",cn,3,2
timer1.interval=2000
end subprivate sub timer1_timer()
debug.print rs("字段")
rs.movenext
end sub
dim rs as new adodb.recordset
rs.open "select * from 表",cn,3,2 debug.print rs("字段")
rs.movenext
end sub
里面读取数据库里面的表,速度很快,根本显示不出我要调的经纬度,从而显示在图层上啊.
Timer1.Interval = 2000
k = 1
End SubPrivate Sub Timer1_Timer()
Dim s
Dim cn As New ADODB. Connection
Dim rs as New ADODB.Recordset
cn.open......
s = "select * from [table] where id=" & k
rs.open s,cn,1,3
List1.AddItem rs.Fields(1)
k = k + 1
Set rs = Nothing
Set cn= Nothing
End Sub