Visual Basic 2008 - Automatic USB Port Connection Question

vb6 Romania
  • 9 years ago

    I am using Visual Basic Express 2008.  Is there a way to check each USB port for device captions(description) and then when the device is found, connect to that device?

    I have an application that uses 2 USB devices; I currently have to tell the programme which port each USB device is on; for example by using the line Device.Device_Connection(12) in the main class:

    Class Device

    Function Connection (ByVal COM_Port)

    SerialPort.PortName = "COM" & COM_Port.To String

    SerialPort. ect ect   .Open()

    Problem is..by nature of the application...these ports keep changing (the devices are the same) 

    Is there a way that the status of every port can be automatically detected, for example.. For Each port: check device ID or caption, if caption is the Required Device then connect to that port? 

    I think that this may be done by accessing WMI or with the My.Computer.Ports statement however I am unsure how to go about using these?

     Any advice or pointers recieved with thanks 

     

     

      

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth