System.SerialPortCount

From Xojo Documentation

Read-Only Property (As Integer )
IntegerValue = aSystem.SerialPortCount

Supported for all project types and targets.

Returns the number of serial ports available.

Example

The following displays the names of the serial ports on the computer:

For i As Integer = 0 To System.SerialPortCount - 1
MsgBox(System.SerialPort(i).Name)
Next