20 | 09 | 2017

Add available COM ports to list

The function below adds all available COM ports to a combobox. 

 Imports System
 Imports System.IO.Ports
 Imports System.Threading

 Function AddCom2Combo(ByVal cbPort As ComboBox)
     ' Get a list of serial port names.
     Dim ports As String() = SerialPort.GetPortNames()
     ' Show a label with Action information on it
     cbPort.Text = "The following serial ports were found:"
     ' Put each port name Into a comboBox control.
     Dim port As String
     For Each port In ports
    Next port
     ' Select the first item in the combo control
    cbPort.SelectedIndex = 0
End Function

Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles