首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

请教怎么用VB解决这个有关问题

2012-01-20 
请问如何用VB解决这个问题?PrivateSubxxxxxxx_Connect()DimstrAsStringstr1Ifxxxxxxx.StatesckConnected

请问如何用VB解决这个问题?
Private   Sub   xxxxxxx_Connect()
Dim   str   As   String
str   =   1
If   xxxxxxx.State   =   sckConnected   Then   xxxxxxx.SendData   str
End   Sub

我想每隔1分钟发一次字符,有什么好办法解决吗?



[解决办法]
如果在一次连接中
Private Sub xxxxxxx_Connect()
Dim str As String
str = 1
Dim t1 As Date, t0 As Date
t0 = Now
dim i as integer
Do While i < 10 '假设只发送10次,可另行设置条件
t1 = Now
If Abs(DateDiff( "n ", t1, t0)) > = 1 Then
If xxxxxxx.State = sckConnected Then xxxxxxx.SendData str
i = i + 1
t0 = Now
End If
DoEvents
Loop
End Sub
也可以每次连接、发送后断开,过一分钟后再连接,发送。
[解决办法]
如果是按你说的每发一次,段开,一分钟后再连接,再发呢?

在timer控件中实现
[解决办法]
断开数据库,再连接,再打开数据库

你想想你要消耗多少的时间与内存

我觉得用Timer空间,每隔1分钟进行访问一次,这样的话,就不会断开数据库
[解决办法]
一次性的把字符取出来,每过一分钟,发送一个字符
[解决办法]
把发送放到时间记时器里面,时钟的时间间隔是1M

Private Sub xxxxxxx_Connect() 里面只要把一个标记设置为真
flgConnect = true

Private Sub Timer1_Timer()
if flagConnect = true then

'发送数据

end if
End Sub

热点排行