Dim boTimeout as Boolean ' This should be in the Declaration Section
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 2000 ' 2000 = 2 Seconds
End Sub
Private Sub Timer1_Timer()
boTimeout = True
End Sub
Private Sub cmdSend_Click()
MSComm1.Output strMyData
'
' Loop until something is received
' or the request times out
'
boTimeout = False
Timer1.Enabled = True
Do Until MSComm1.ComEvent = comEvReceive Or boTimeout = True
DoEvents
Loop
If boTimeout = False Then
Do
strData = strData & MSComm1.Input
Loop Until MSComm1.InBufferCount = 0
If strData = "OK" then
'
' Chip has responded with OK
'
Else
'
' Chip has responded with something else
'
End If
Else
MsgBox "Equipment hasn't responded after " & Timer1.Interval / 1000 & " Seconds"
End if
End Sub