Hi
I am connected to a peice of equipment that sends string of hex data every 500ms. Each string is terminated by a carriage return and a line feed is also inserted, an example would be;
01 54 1F OK<CR>
<LF>
02 D0 1F OK<CR>
<LF>
I have the following code to attempt ot collect the strings;
Private Sub IT_Comm()
Dim MyString As String
Dim MyChar As Variant
Dim Done As Boolean
MSComm1.InputLen = 1 'Get one character at a time
MyString = "" ' Clears variable
MyChar = "" ' Clears variable
Done = False
Do
MyChar = MSComm1.Input 'Get a Character from the comport
If MyChar = Chr(13) Then 'If it is a terminiting character
Exit Do 'Jump out of loop
Else
MyString = MyString & MyChar 'otherwise concatenate it to the string
txtTerm1.Text = MyString 'Displays the collected string
txtTerm2.Text = MyChar 'Displays each character collected
End If
Loop Until Done 'Loop forever, I need to add a time out timer
End Sub
I am using the comEvReceive to call this sub maybe that is my problem? TxtTerm1 and TxtTerm2 are noting but a simple text box just so I can see what I am getting.
Here is the problem, I get 1 complete string and that is it, it is a great snap shot but I need it to clear the old string and constantly reload the most current string. I was also attempting to view each character collected using TxtTerm2 but I see a solid black bar and that is it, maybe it is some Ascii character I am not sure.
As you can see my code is rough but I am trying to learn so please help if you can, and thank you for trying.
Regards
Randy
I am connected to a peice of equipment that sends string of hex data every 500ms. Each string is terminated by a carriage return and a line feed is also inserted, an example would be;
01 54 1F OK<CR>
<LF>
02 D0 1F OK<CR>
<LF>
I have the following code to attempt ot collect the strings;
Private Sub IT_Comm()
Dim MyString As String
Dim MyChar As Variant
Dim Done As Boolean
MSComm1.InputLen = 1 'Get one character at a time
MyString = "" ' Clears variable
MyChar = "" ' Clears variable
Done = False
Do
MyChar = MSComm1.Input 'Get a Character from the comport
If MyChar = Chr(13) Then 'If it is a terminiting character
Exit Do 'Jump out of loop
Else
MyString = MyString & MyChar 'otherwise concatenate it to the string
txtTerm1.Text = MyString 'Displays the collected string
txtTerm2.Text = MyChar 'Displays each character collected
End If
Loop Until Done 'Loop forever, I need to add a time out timer
End Sub
I am using the comEvReceive to call this sub maybe that is my problem? TxtTerm1 and TxtTerm2 are noting but a simple text box just so I can see what I am getting.
Here is the problem, I get 1 complete string and that is it, it is a great snap shot but I need it to clear the old string and constantly reload the most current string. I was also attempting to view each character collected using TxtTerm2 but I see a solid black bar and that is it, maybe it is some Ascii character I am not sure.
As you can see my code is rough but I am trying to learn so please help if you can, and thank you for trying.
Regards
Randy