0% found this document useful (0 votes)
9 views3 pages

Serial Port Connection Management Code

This code defines a Windows form application that communicates with a serial port. It contains handlers for buttons to connect/disconnect to a serial port, send data, and receive incoming data on a timer. When certain buttons are clicked, it sends individual characters ("R", "O", "L", "J") over the serial port.

Uploaded by

Jose Regino
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Serial Port Connection Management Code

This code defines a Windows form application that communicates with a serial port. It contains handlers for buttons to connect/disconnect to a serial port, send data, and receive incoming data on a timer. When certain buttons are clicked, it sends individual characters ("R", "O", "L", "J") over the serial port.

Uploaded by

Jose Regino
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Public Class Form1

Dim strBufferOut As String


Dim strBufferIn As String

Private Sub TextBox1_TextChanged(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]

End Sub

Private Sub btnDeterrminarConexion_Click(ByVal sender As [Link], ByVal e


As [Link]) Handles [Link]
[Link]()
For Each PuertoDisponible As String In [Link]
[Link](PuertoDisponible)

Next
If [Link] > 0 Then
[Link] = [Link](0)
[Link]("SELECCIONE EL PUERTO A TRABAJAR")
[Link] = True
Else

[Link]("NINGUN PUERTO ENCONTRADO")


[Link] = False
[Link] = False
[Link]()
[Link] = ("")
End If
End Sub

Private Sub btnConectar_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
If [Link] = "CONECTAR" Then
[Link] = [Link]
[Link] = "desconectar"
[Link] = True
[Link] = True
[Link]()
[Link] = True
[Link] = True

Else
[Link] = "desconectar"
[Link] = "CONECTAR"
[Link] = False
[Link] = False
[Link]()
End If
End Sub

Private Sub btnEnviarDato_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
strBufferOut = [Link]
[Link](strBufferOut)
End Sub

Private Sub tmrTimer_Tick(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
strBufferIn = [Link]
If strBufferIn <> "" Then
[Link] = strBufferIn
strBufferIn = ""
[Link]()

End If
End Sub

Private Sub Form1_Load(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
strBufferOut = ""
strBufferIn = ""
[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
strBufferOut = "R"
[Link](strBufferOut)
[Link] = True
[Link] = False

End Sub

Private Sub Button2_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
strBufferOut = "O"
[Link](strBufferOut)
[Link] = True
[Link] = False

End Sub

Private Sub Button3_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
strBufferOut = "L"
[Link](strBufferOut)
[Link] = True
[Link] = False
End Sub

Private Sub Button4_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
strBufferOut = "J"
[Link](strBufferOut)
[Link] = True
[Link] = False
End Sub
End Class

You might also like