I am new to VB6 programming and have some difficulties...
Here is my question:
I have a For Loop running, wherein there should be some communicating with a serial port to get new data (will be implemented later), updating a data array and the corresponding graph.
This works all fine...
But then: When I apply a delay within the For Loop to wait some time (about 1 second) for the next loop iteration to start I get a 'Runtime error: Overflow' message.
How can I avoid this?
Thanks in advance!
Private Declare Function GetTickCount Lib "kernel32" () As Integer Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Integer) Public Sub Delay(ByVal delayms As Integer) Dim delayTime As Long delayTime = GetTickCount + delayms Do Until GetTickCount >= delayTime Sleep 10 DoEvents Loop End Sub Public Sub GetData() Dim i As Integer Dim Start, Finish, Duration As Integer For i = 1 To End Start = GetTickCount ' Get new Data ... ' Refresh DataArray ... ' Refresh Graph ... Finish = GetTickCount Duration = Start - Finish 'Delay: Loop repetition after 1s Delay (1000 - Duration) Next i End Sub