How to implement a sleep sub in a serial port
I need to implement or add a sleep sub routine in Ms Access between the commwrite & commread so that I'm sure that all the data received from the gadget is read and received into my database. Now below is my draft sub routine see how to improve it. The gadget writes all the invoices without problems see attached screen, the only issue here is receiving that why the suggestion for a sleep sub:
Dim strData as string
Dim strDataComplete as string
strDataComplete = ""
Do While True ' Loop until serial port is read
Sleep 1000
lngStatus = CommRead(intPortID, strData, 100000) 'For 100000 is the max data length you want read, change to suite
Sleep 1000
If lngStatus = 0 Then
'Keep polling to see if serial has data
ElseIf lngStatus <> 0 Then
strDataComplete = strData 'Put data pulled from serial port here
End If
If lngStatus = 0 And strDataComplete <> "" Then
Exit Do ' Exit loop when all data is read
End If
Loop
Doesn't the VBA sleep helps ? : https://www.myonlinetraininghub.com/pausing-or-delaying-vba-using-wait-sleep-or-a-loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.