List available com ports

jon.Haigh

New member
Joined
Oct 17, 2011
Messages
2
Programming Experience
Beginner
Hello

I am very new to .net and I am trying to figure out the best way to get a list of all of the currently available com ports. I have tried some code I found on the forum and it isn't working.

Dim ports As String() = SerialPort.GetPortNames()




Dim port As String
Dim x As SerialPort
For Each port In ports
x = port
If x.IsOpen Then
MessageBox.Show("hello")




End If
Next port

it says that the port string cannot be saved to x

Any ideas as to how I can correct this or do it better. Thanks!
 

jon.Haigh

New member
Joined
Oct 17, 2011
Messages
2
Programming Experience
Beginner
Thank you for the help. I corrected the code and it is working by showing me the com's of all my serial ports. Why doesn't it show USB ports though? shouldn't it? If not what else do I need to do? Thanks
 
Top Bottom