Imports System.IO.Ports
Public Class Form1
Dim instance As New SerialPort
Dim textMsg As String
Private mySerialPort As New SerialPort
Public Sub Open()
Dim instance As New SerialPort
'Setup Proceedure
With mySerialPort
.PortName = "COM4"
.BaudRate = 300
.DataBits = 8
.Parity = Parity.None
.StopBits = StopBits.One
.Handshake = Handshake.None
End With
Try
instance.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
Me.Close()
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
'Writing Data
textMsg = "00100"
instance.Write(Text)
End Sub
End Class
Can anyone tell me what is wrong with this code? I have tried several things and I still get the error message that the port is closed. Any help will be appreciated.
Michael

New Topic/Question
Reply




MultiQuote




|