CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2023

    Help with finding com ports

    Greetings from Pennsylvania.

    I have a VB6 program that can send and receive serial data with an Arduino board.
    It would be helpful if I could acquire the com port the Arduino is using on start up
    of the VB program.

    My attempts to use the Microsoft example results in a syntax error. I do not understand
    the example requirements enough to continue. Could one of you folks explain to me what I need
    to do to make the compiler happy?

    'have set: Project->References->System_Windows_Forms
    Private Sub Command1_Click()
    ' Show all available COM ports.
    For Each sp As String In My.Computer.Ports.SerialPortNames
    ListBox1.Items.Add (sp)
    End Sub

    This example requires:
    A project reference to System.Windows.Forms.dll.

    Access to the members of the System.Windows.Forms namespace.
    Add an Imports statement if you are not fully qualifying member names in
    your code. For more information, see Imports Statement


  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: Help with finding com ports

    I suggest you re-post this on this site's sister-site at:
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

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