Share via


VB.NET: Identify the Available Serial Port on the PC

with this sample code you can identify the available serial port on the PC, running a ForEach iteration SerialPortNames property vb.net and GetPortNames method c#.

Sample code VB.NET

Private Sub  BtnFindSerialPort_Click(sender As System.Object, e As  System.EventArgs) Handles BtnFindSerialPort.Click 
  For Each  ports In  My.Computer.Ports.SerialPortNames 
   MessageBox.Show("Serial port avialible" & " "  & ports) 
  Next
End Sub