Ports.SerialPortNames Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of the names of the serial ports on the computer.
public:
property System::Collections::ObjectModel::ReadOnlyCollection<System::String ^> ^ SerialPortNames { System::Collections::ObjectModel::ReadOnlyCollection<System::String ^> ^ get(); };
public System.Collections.ObjectModel.ReadOnlyCollection<string> SerialPortNames { get; }
member this.SerialPortNames : System.Collections.ObjectModel.ReadOnlyCollection<string>
Public ReadOnly Property SerialPortNames As ReadOnlyCollection(Of String)
Property Value
A collection of the names of the serial ports on the computer.
Examples
This example loops over all the strings that the My.Computer.Ports.SerialPortNames
property returns. These strings are the names of the available serial ports on the computer.
Typically, a user selects which serial port the application should use from the list of available ports. In this example, the serial port names are stored in a ListBox control. For more information, see ListBox Control.
Sub GetSerialPortNames()
' Show all available COM ports.
For Each sp As String In My.Computer.Ports.SerialPortNames
ListBox1.Items.Add(sp)
Next
End Sub
This example requires:
For more information, see How to: Show Available Serial Ports.
Remarks
The My.Computer.Ports.SerialPortNames
property gets a collection of the names of the serial ports on the computer.
The following table lists an example of a task involving the My.Computer.Ports.SerialPortNames
property.
To | See |
---|---|
Show available serial ports | How to: Show Available Serial Ports |
Availability by Project Type
Project type | Available |
---|---|
Windows Application | Yes |
Class Library | Yes |
Console Application | Yes |
Windows Control Library | Yes |
Web Control Library | No |
Windows Service | Yes |
Web Site | No |