Problems with binary data using MsComm32.ocx of VB 5.0 
Author Message
 Problems with binary data using MsComm32.ocx of VB 5.0

Hello,

I use VB 5.0 on Windows NT 4.0.
I did install the Servicepacks 2 for VB and 3 for NT.

I have to send and receive binary data over a serial port.
I found some tips about using arrays of byte instead of a string.

I initialize as follows:
MsComm1.InputMode = comInputModeBinary
MsComm1.NullDiscard = False

Sending the data within a byte array  works correct.
Dim DataBytes(1 to 8) As Byte
Dim i As Integer

        For i = 1 to 8
                DataBytes(i) = i
        Next i

        MsComm1.Output = DataBytes()

But when receiving data, I get no byte array, I get a string and must
transform it into a byte array.

Dim Temp as String
Dim i, j as Integer
Dim DataBytes(1 to 10) as Byte

        j = MsComm1.InBufferCount
        Temp = MsComm1.Input
        For i = 1 to j
                DataBytes(i) = AscB(MidB(Temp, i, 1))
        Next i

Because of the Unicode support of VB, I have to use AscB and MidB
instead of Asc and Mid.

Does anybody now an easier way of transmitting binary data?

Many thanks for your comments.

By

        l
Uwe Hercksen

For EMail response, please replace nospam with zew
--------------------------------------------------
Elektronikwerkstatt Uni. Erlangen
Cauerstr. 5
D91058 Erlangen



Sat, 08 Apr 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MSCOMM32.OCX, how to read binary data

2. How to Transmit and Receive Binary Data using MSCOMM32

3. VB 5.0 MSCOMM32.OCX vs. VB 4.0 MSCOMM32.OCX

4. Using MsComm32.ocx without loading VB

5. how to send binary data using winsock.ocx

6. Need help in using mscomm32 binary mode

7. Fixing binary problems with mscomm32

8. Fixing binary problems with mscomm32

9. Passing binary data to VB from OCX

10. Errors reading data with MSComm32.ocx

11. Putting Recieved Data in a Label.Caption with MSCOMM32.OCX

12. App freezes using mscomm32.ocx

 

 
Powered by phpBB® Forum Software