28 | 04 | 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
        cbPort.Items.Add(port)
 
    Next port
     ' Select the first item in the combo control
    cbPort.SelectedIndex = 0
End Function
Login

Sign up now and upload your code to the website.

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