VB.Net Tutorial/Development/SerialPort — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:53, 26 мая 2010
My.Computer.Ports.SerialPortNames
Option Strict On
Imports System.Collections.ObjectModel
Public Module PortsTest
Public Sub Main()
Dim ports As ReadOnlyCollection(Of String) = _
My.ruputer.Ports.SerialPortNames
For Each port As String In ports
Console.WriteLine(port)
Next
End Sub
End Module
COM3
Write to Serial Port
Public Class Tester
Public Shared Sub Main
Dim com1Port As IO.Ports.SerialPort = Nothing
Try
com1Port = My.ruputer.Ports.OpenSerialPort("COM1")
com1Port.WriteLine("serialData")
com1Port.Write("serialData")
com1Port.Close()
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
If (com1Port IsNot Nothing) Then com1Port.Dispose()
com1Port = Nothing
End Try
End Sub
End Class
The port "COM1" does not exist.