Hello vb. users.
I have a problem with a communication program i recently wrote :
I made a program connecting a computer with his com(1) I/O to a datalogger system. with this i sample inputs from the datalogger.
My problem is when the program works and I do somthing else - I'll explain :

When the program runs , if i for instance take the program form and drap it to someplace else in the screen the connection loop stops , and if i click the form or open another form or a program ,the connection with the datalogger (made all the time - loop) suddenly stops ! thats why i get error in connection. the communication is made by the mscomm32.ocx and in rs232 in 19200 baudrate.

Here is a simple code to try to explain you what i do :

Call block_out ' this block contain the data send to datalogger requesting inputs
MSComm1.Output = hb

Call delay(0.2) ' wait for 0.2 sec. for the datalogger to send back data
Do While MSComm1.InBufferCount > 0
DoEvents ' this is for calling the mscomm_oncomm event
Loop

ReDim Preserve rcv(f - 1)
Call block_in ' this sub take the rcv array , analyze it and shows the sampled inputs on a textbox
f = 0
MSComm1.InBufferCount = 0
Loop


Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent

' when receiving byte - insert to rcv() array
Case comEvReceive
buf = MSComm1.Input
rcv = buf
f = Len(buf) * 2
End Select
End Sub

This code is realy a small part of the program , but he shows how the loop in connection is made.
I think that my problem is the DoEvents command , but it's the only way for me to let the
mscomm_oncomm fire!
By the way the connection made in binary

Thanks in advance TOMER. ([email protected])