| Add available COM ports to list |
|
|
|
| Tutorials | |||
|
The Function below adds all available COM ports to a combobox. 1 Imports System 2 Imports System.IO.Ports 3 Imports System.Threading 4 5 6 Function AddCom2Combo(ByVal cbPort As ComboBox) 7 8 ' Get a list of serial port names. 9 Dim ports As String() = SerialPort.GetPortNames() 10 ' Show a label with Action information on it 11 cbPort.Text = "The following serial ports were found:" 12 13 ' Put each port name Into a comboBox control. 14 Dim port As String 15 For Each port In ports 16 cbPort.Items.Add(port) 17 18 Next port 19 ' Select the first item in the combo control 20 cbPort.SelectedIndex = 0 21 End Function
|



Comments
RSS feed for comments to this post