Codigo visual

Solo disponible en BuenasTareas
  • Páginas : 3 (505 palabras )
  • Descarga(s) : 0
  • Publicado : 10 de noviembre de 2011
Leer documento completo
Vista previa del texto
Imports System
Imports System.IO.Ports
Imports System.Threading

Public Class PortChat
Shared _continue As Boolean
Shared _serialPort As SerialPort

Public Shared Sub Main()Dim name As String
Dim message As String
Dim sComparer As StringComparer = StringComparer.OrdinalIgnoreCase
Dim readThread As Thread = New Thread(AddressOf Read)' Create a new SerialPort object with default settings.
_serialPort = New SerialPort()
' Allow the user to set the appropriate properties.
_serialPort.PortName =SetPortName(_serialPort.PortName)
_serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate)
_serialPort.Parity = SetPortParity(_serialPort.Parity)
_serialPort.DataBits =SetPortDataBits(_serialPort.DataBits)
_serialPort.StopBits = SetPortStopBits(_serialPort.StopBits)
_serialPort.Handshake = SetPortHandshake(_serialPort.Handshake)
' Set theread/write timeouts
_serialPort.ReadTimeout = 500
_serialPort.WriteTimeout = 500

_continue = True
readThread.Start()Console.Write("Name: ")
name = Console.ReadLine()

Console.WriteLine("Type QUIT to exit")

While (_continue)
message = Console.ReadLine()

IfsComparer.Equals("quit", message) Then
_continue = False
_serialPort.WriteLine( _
String.Format(": {1}", name, message))
End Ifend while

End Sub

Public Shared Sub Read()
While (_continue)
Dim message AsString = _serialPort.ReadLine()
Catch ex As TimeoutException
' Do nothing
End Try
End While
End Sub...
tracking img