:8+3423,
to
3423
I have managed to to find the necessary code to perform this filtering. But when used in the program I made I get an error that says "NullReferenceException was unhandled" and that "Object reference not set to an instance of an object". It then suggest that I use the "new" keyword to create an object instance. The codes I use for the filtering is:
steps = output_data.Substring(4)
steps = steps.Substring(0, steps.Length - 2)
I use these as since the position of the ASCII is fixed.
Please advice
Codes for program are as shown below:
Expand|Select|Wrap|Line Numbers
- Public Class Form1
- Dim s As String
- Dim output_data As String
- Dim steps As String
- Dim colon8 As String = "Chr(4) & Chr(49) & Chr(49) & Chr(58) & Chr(56) & Chr(5)"
- 'code in hex is 04 31 31 3A 38 05
- 'code in ASCII is 11:8
- Private Sub Activate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Activate.Click
- COMPort1.Open()
- End Sub
- Private Sub Deactivate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Deactivate.Click
- COMPort1.Close()
- End Sub
- Private Sub COMPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles COMPort1.DataReceived
- output_data &= COMPort1.ReadExisting
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Timer1.Enabled = Not Timer1.Enabled
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- COMPort1.Write(Chr(4) & Chr(49) & Chr(49) & Chr(58) & Chr(56) & Chr(5))
- steps = output_data.Substring(4)
- steps = steps.Substring(0, steps.Length - 2)
- TextBox1.Text() = steps
- steps = ""
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- End Class