OK, you can do this, but you have to be carefull.
If you have a loop of code that is executing, the only way you can wait for the OnComm event is to have another loop inside the first one, with a DoEvents staement in there. Along with a couple of global variables. example
Global variables
Public OnComm_Trigger as Boolean
Public OnComm_Data as String
Inside your Mainloop, you send out the data to the COM port and then do this...
OnComm_Trigger = False
Do Until OnComm_Trigger = True
DoEvents
Loop
And inside the OnComm event, you would have to assign the incoming data to your OnComm_Data variable.
Comm1_OnComm
OnComm_Data = Comm1.Input
OnComm_Trigger = True
End Sub
OK, the problem is that:
1: The DoEvents statement will cause any pending events to be processed. This includes mouse clicks. So you have to protect yourself so that the user can't accidentally do something else in the middle of the proceedure.
2: You have to be sure that the OnComm event is going to get all of the data that you are expecting from the com port, so you have to set your OnComm threshold to the appropriate value.
3: You need to put some sort of timeout into the loop that waits for the oncomm event, so that if the com port does not get the data, it will not put your program in an infinite loop.
Sorry, did not have a lot of time to write this. Hope it helps you in the right direction.
Robert