first of all i would like to say this site is really a help.
my problem is how will i know how bytes the control actually recieve. my program sends bytes to a terminal as commands and then the terminals sends bytes as response. so far, my program works because initially i know how many bytes i will receive but is there a way to know how many bytes exactly the control receive. I attached my code and any help,tips and suggestions would greatly be appreciated. Thank you very much.
Private Sub MSCOMM1_OnComm()
Select Case MSCOMM1.CommEvent
Case comEvReceive
myBuffer = MSCOMM1.Input
status = False
End Select
End Sub
Private Sub MyCommand_Click()
Dim InString As Variant
Dim dummy
Dim MyOption As Single
' Use COM1.
If MSCOMM1.PortOpen Then
MSCOMM1.PortOpen = False
End If
MSCOMM1.CommPort = 1
MSCOMM1.Settings = "38400,N,8,1"
' Open the port.
MSCOMM1.PortOpen = True
MSCOMM1.InBufferCount = 0
MSCOMM1.RThreshold = 14 ' i expect 14 bytes to receive
status = True
MSCOMM1.InputMode = comInputModeBinary
mystring(1) = &H1
mystring(2) = &H9
mystring(3) = &H0
mystring(4) = &H10
mystring(5) = &H82
mystring(6) = &H20
mystring(7) = &H6
mystring(8) = &HBC
mystring(9) = &H43
MSCOMM1.Output = mystring
Do
DoEvents
Loop While status
'code from cubeE101 thank you very much josh
Dim intc1 As Single
Dim strwork As String
Text1 = ""
If IsArray(myBuffer) Then
For intc1 = LBound(myBuffer) To UBound(myBuffer)
strwork = Right("0" & Hex$(myBuffer(intc1)), 2)
Text1 = Text1 & " " & strwork
Next
End If
End Sub
my problem is how will i know how bytes the control actually recieve. my program sends bytes to a terminal as commands and then the terminals sends bytes as response. so far, my program works because initially i know how many bytes i will receive but is there a way to know how many bytes exactly the control receive. I attached my code and any help,tips and suggestions would greatly be appreciated. Thank you very much.
Private Sub MSCOMM1_OnComm()
Select Case MSCOMM1.CommEvent
Case comEvReceive
myBuffer = MSCOMM1.Input
status = False
End Select
End Sub
Private Sub MyCommand_Click()
Dim InString As Variant
Dim dummy
Dim MyOption As Single
' Use COM1.
If MSCOMM1.PortOpen Then
MSCOMM1.PortOpen = False
End If
MSCOMM1.CommPort = 1
MSCOMM1.Settings = "38400,N,8,1"
' Open the port.
MSCOMM1.PortOpen = True
MSCOMM1.InBufferCount = 0
MSCOMM1.RThreshold = 14 ' i expect 14 bytes to receive
status = True
MSCOMM1.InputMode = comInputModeBinary
mystring(1) = &H1
mystring(2) = &H9
mystring(3) = &H0
mystring(4) = &H10
mystring(5) = &H82
mystring(6) = &H20
mystring(7) = &H6
mystring(8) = &HBC
mystring(9) = &H43
MSCOMM1.Output = mystring
Do
DoEvents
Loop While status
'code from cubeE101 thank you very much josh
Dim intc1 As Single
Dim strwork As String
Text1 = ""
If IsArray(myBuffer) Then
For intc1 = LBound(myBuffer) To UBound(myBuffer)
strwork = Right("0" & Hex$(myBuffer(intc1)), 2)
Text1 = Text1 & " " & strwork
Next
End If
End Sub