Hi I am creating a VBA application that receives 4 bytes from RS232 on the serial port. When the byte with the decimel value 230 is received I want to store the next two bytes as X and Y respectively.
I want to create some sort of loop or counter where 230 has the count value 0 represents 230 and then count=1 stores the next byte (i.e. X value) and count=2 stores the third byte i.e. Y.
Can anyone help me? I know the counter doesn't really do anything but I'm not sure how to go about changing it
Thannks,
Niamh
I want to create some sort of loop or counter where 230 has the count value 0 represents 230 and then count=1 stores the next byte (i.e. X value) and count=2 stores the third byte i.e. Y.
Code:
Private Sub MSComm1_OnComm() Dim Data As String Dim ID As Long Dim X As Long Dim Y As Long Dim Z As Long Dim Count as Integer Select Case MSComm1.CommEvent Case comEvReceive Data = MSComm1.Input If (Data) = 230 Then Count = Count +1 End If Select Case Count Case 1 X = MSComm1.Input Case 2 Y = MSComm1.Input End Select End Sub
Thannks,
Niamh
Comment