PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Comm Port-VBForums
Results 1 to 5 of 5

Thread: Comm Port

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011

    Comm Port


    How to get the Number of USB to Serial Port Comm Port . Number gets frequently changed.


  2. #2
    Frenzied Member
    Join Date
    Oct 2001
    Idaho Falls, Idaho USA

    Re: Comm Port

    You can check Device Manager. Note that the COM port numbers can go way up to at least 98 or 99. You may want to look into limiting this by a registry setting so that they don't exceed 10 or so, since some software can't handle higher COM port numbers.

  3. #3
    New Member
    Join Date
    Feb 2018

    Re: Comm Port

    Quote Originally Posted by Jagjit View Post

    How to get the Number of USB to Serial Port Comm Port . Number gets frequently changed.

    Why is it changing? Is the Serial com cable being plugged into different USB ports at various times. For example, like where a service tech has to connect to different computers and needs to get his diagonistic reader to receive the signal, which on different computers would be coming over differing ports depending on what port assignments had already been made by the computer for other components?

  4. #4
    Fanatic Member
    Join Date
    Dec 2014
    VB6 dinosaur land

    Re: Comm Port

    This is for .Net so you'll need to convert back to VB6, but this is how I do it.

    VB.Net Code:
    1. Public Function findComDevice(ByVal PartialName As String) As String
    2.         Try
    3.             Dim moReturn As Management.ManagementObjectCollection
    4.             Dim moSearch As Management.ManagementObjectSearcher
    5.             Dim mo As Management.ManagementObject
    6.             moSearch = New Management.ManagementObjectSearcher("Select * from Win32_PnPEntity")
    7.             moReturn = moSearch.Get
    9.             For Each mo In moReturn
    10.                 If IsNothing(mo.Properties.Item("Name").Value) Then Continue For
    11.                 If CStr(mo.Properties.Item("Name").Value).ToUpper.Contains(PartialName.ToUpper) Then
    12.                     'returns something like: "Prolific USB-to-Serial Comm Port (COM17)"
    13.                     Dim IPRegEx As Regex = New Regex("(?<=\().*?(?=\))")
    14.                     Return IPRegEx.Match(mo.Properties.Item("Name").Value.ToString).Value
    16.                 End If
    17.             Next
    18.             Return Nothing
    19.         Catch ex As Exception
    20.             Messagebox.Show(ex.ToString)
    21.             Return Nothing
    22.         End Try
    24.     End Function

  5. #5
    Join Date
    Feb 2006

    Re: Comm Port

    I don't know if this helps you, but I just posted this:

    EnumPorts - Find the system's COM and/or LPT ports

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width