[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Command line parameters with a VB Win32 Console Application

I created a Win32 application and would like to pass parameters to it.  The Main() for a VB application doesn't look anything like .Net C++ Win32:

      Sub Main()

      End Sub

Open in new window


How should the Main() look to accept parameters?

Thanks!
0
John500
Asked:
John500
  • 2
2 Solutions
 
Kyle AbrahamsSenior .Net DeveloperCommented:
http://www.programmers-corner.com/sourcecode/113

Public Sub Main(ByVal sArgs() As String)
        'Note the declaration of the Sub Main line
        'It has the sArgs parameter.  This parameter is handled by
        'the system, and contains any command line arguments.

        If sArgs.Length = 0 Then                'If there are no arguments
            Console.WriteLine("Hello World! <-no arguments passed->") 'Just output Hello World
        Else                                    'We have some arguments            
            Dim i As Integer = 0

            While i < sArgs..Length             'So with each argument
                Console.WriteLine("Hello " & sArgs(i) & "!") 'Print out each item
                i = i + 1                       'Increment to the next argument
            End While

        End If

    End Sub
     
0
 
John500Author Commented:
Ok great!


It all happens so quick.  What should I put in there to make it wait for user input before shutting the window down?

Thanks
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
To make it pause at the end, add this right before the "End Sub":

    Console.WriteLine("Press Enter to Quit")
    Console.ReadLine()
0
 
John500Author Commented:
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now