关于错误6溢出
本帖最后由 bcrun 于 2013-10-30 10:40:14 编辑 最近遇到一个问题,求帮组。表达能力有限,谅解。
在完成的软件中添加一个功能,当设备不在线时,调用以前写好的重连函数。每五秒重连一次。
主要代码如下:
(Picture16_DblClick(1)这个函数在以前就实现,运行一直没有问题的)
Dim one_Time_Count As Long '自动重连计时器
Dim two_Time_Count As Long '自动重连计时器
Dim three_Time_Count As Long '自动重连计时器
Private Sub Timer1_Timer()
one_Time_Count = one_Time_Count + 1
two_Time_Count = two_Time_Count + 1
three_Time_Count = three_Time_Count + 1
end sub
Private Sub Timer2_Timer()‘重连的调用
On Error Resume Next
If Picture16(1).Visible = True Then
If one_Time_Count >= 5 Then
Call Picture16_DblClick(1)
one_Time_Count = 0
End If
End If
If Picture16(2).Visible = True Then
If two_Time_Count >= 5 Then
Call Picture16_DblClick(2)
two_Time_Count = 0
End If
End If
If Picture16(3).Visible = True Then
If three_Time_Count >= 5 Then
Call Picture16_DblClick(3)
three_Time_Count = 0
End If
End If
End Sub
Dim Time_Count(1 To 3) As Long '自动重连计时器
Dim i As Integer
Private Sub Timer1_Timer()
For i = 1 To 3
If Time_Count(i) < 5 Then Time_Count(i) = Time_Count(i) + 1
If Picture16(i).Visible And Time_Count(i) = 5 Then
Call Picture16_DblClick(i)
Time_Count(i) = 0
End If
Next i
End Sub
2 如果 Picture16_DblClick 不是占用时间很长,就不需要 2 个定时器。