MSComm: Closing the port after data received 
Author Message
 MSComm: Closing the port after data received

Using the (abbreviated) code below, I am successfully receiving and
displaying my received data in the textbox.

I also have a "Disconnect" button which works fine.

However, I would like to automatically close the port as soon as this data
has been processed and displayed, but have not been able to manage this
without 'losing' some of the data, ie., not all the received data is
displayed.

How can I automatically close the port ?

Thanks,

Alan

Private Sub MSComm1_OnComm()
    Dim i As Integer
    Dim Buffer As Variant
    Dim arrInBuffer() As Byte

    ' Check what type of event has happened

    Select Case MSComm1.CommEvent
        ' Errors

        ' Events

        Case comEvReceive
            ' Received RThreshold # of chars. RThreshold = 1
                If MSComm1.PortOpen Then
                  Buffer = comPort.Input
                  arrInBuffer = Buffer
                  For i = 0 To UBound(arrInBuffer)
                    txtData = txtData + ProcessData(arrInBuffer(i))
                  Next
                End If      ' MSComm1.PortOpen

    End Select
End Sub                           ' MSComm1_OnComm
'



Sat, 18 Sep 2004 02:56:20 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MSCOMM - Port data, Mscomm no data

2. mscomm - send/receive from serial port

3. Closing Comm Port with Sportster 28.8K (MSCOMM)

4. Closing Comm Port with Sportster 28.8 (MSCOMM)

5. Closing Comm Port with Sportster (MSCOMM)

6. VB MSCOMM close port w/o hang-up

7. HOW RECEIVE BINARY DATA WITH MSCOMM AND STORE THEM AS ASCII

8. Using MSComm to receive large amounts of data

9. MSComm - not receiving "0" data correctly

10. HOW RECEIVE BINARY DATA WITH MSCOMM AND STORE THEM AS ASCII

11. mscomm, error in receiving data

12. Using MSCOMM to send/receive data

 

 
Powered by phpBB® Forum Software