Torna al Thread

Public Class Form1 Private Sub Ricezione() Handles SerialPort1.DataReceived Dim Ricezione(100) As Char Dim i As Integer = 0 SerialPort1.Read(Ricezione, 0, 10) For i = 0 To 10 Label1.Text = Label1.Text & Ricezione(i) Next End Sub Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Try SerialPort1.Close() Catch ex As Exception MsgBox("Impossibile Chiudere la Porta Seriale", MsgBoxStyle.Critical) End Try End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With SerialPort1 .PortName = "COM26" .BaudRate = 9600 .StopBits = IO.Ports.StopBits.One .DataBits = 8 .Parity = IO.Ports.Parity.None .RtsEnable = False .ReceivedBytesThreshold = 1 Try .Open() Catch ex As Exception MsgBox("Impossibile Aprire la Porta Seriale", MsgBoxStyle.Critical) End Try End With End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5