Vb.net code to read from ComPort and display!!

Public Class Form1
Dim c1 As Char
  

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived


        Dim str As String
        str = ""
        c1 = Convert.ToChar(SerialPort1.ReadByte())
        If (c1 <> "") Then
            MsgBox(c1)
        End If

    End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With SerialPort1

            .BaudRate = 9600
            .Parity = System.IO.Ports.Parity.None
            .DataBits = 8
            .StopBits = System.IO.Ports.StopBits.One
            .Handshake = System.IO.Ports.Handshake.None
            If .IsOpen = False Then
                .Open()
            End If
        End With

    End Sub
End Class




THANK YOU FOR VISITING..!!
PLEASE COMMENT

No comments:

Post a Comment