Visual Basic - Sending characters to serial port

  • Thread starter Thread starter Triododjer
  • Start date Start date
T

Triododjer

Guest
Hello,

I am trying to send hex or characters to serial port, and it work's fine from 0 to 127 (&H7F).
From 128 (&H80) to 255 (&HFF) the output is always 63 (3F) ( '?' in ASCII). It seems that can not handle extended ASCII characters.

How can i overcame this situation?


Here's the code i am using:


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim a, a1, a2, a3, a4, a5 As String

SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.Two

SerialPort1.Open()

a1 = TextBox1.Text
a2 = TextBox2.Text
a3 = TextBox3.Text
a4 = TextBox4.Text
a5 = TextBox5.Text

a = Chr(a1) + Chr(a2) + Chr(a3) + Chr(a4) + Chr(a5)

SerialPort1.Write(a)

SerialPort1.Close()

End Sub


Thanks in advance

Continue reading...
 
Back
Top