
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