Computer.Ports Property

Gets an object that provides a property and a method for accessing the computer's serial ports.

Namespace:  Microsoft.VisualBasic.Devices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public Ports Ports { get; }

Property Value

Type: Microsoft.VisualBasic.Devices.Ports
The My.Computer.Ports object.

This property provides easy access to the My.Computer.Ports object. For more information, see Ports object.

Availability by Project Type

Project type

Available

Windows Forms Application

Yes

Class Library

Yes

Console Application

Yes

Windows Forms Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

This example describes how to send strings to the computer's COM1 serial port.

The Using block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a Try...Catch...Finally block with a call to use the Close method.

The WriteLine method sends the data to the serial port.

Sub SendSerialData(ByVal data As String)
    ' Send strings to a serial port. 
    Using com1 As IO.Ports.SerialPort = 
            My.Computer.Ports.OpenSerialPort("COM1")
        com1.WriteLine(data)
    End Using 
End Sub

For more information, see How to: Send Strings to Serial Ports in Visual Basic.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft