+ Reply to Thread
Results 1 to 3 of 3

Thread: Reading Command line arguments in VB.NET

  1. #1
    Moderator Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe's Avatar
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Age
    16
    Posts
    8,777
    Blog Entries
    5

    Reading Command line arguments in VB.NET

    I will show you how to make a program which reads the Command line arguments from a program, it's pretty easy if you know how to do it


    First we declares a ReadOnlyCollection to store the value from our commandline.

    Code:
            Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
    The to get them one by one it's just to refer to its index, in the example below a messagebox will pop up with the arguments one by one.

    Code:
            For i As Integer = 0 To CommandLineArgs.Count - 1
                MessageBox.Show(CommandLineArgs(i))
            Next

    This was actually all the code but before publishing you need to remember to uncheck the "use .deploy file extension" checkbox:









    Now after publishing you will get the .exe file. If you create a shortcut to this .exe file you can add command line arguments to it as shown in the image below:




    Our program can now read these argument and one messagebox showing "Argument1" will be shown and then one showing "Argument2".


    That was it. Hope you liked it

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,662
    Blog Entries
    57

    Re: Reading Command line arguments in VB.NET

    I like +rep
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  3. #3
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: Reading Command line arguments in VB.NET

    Very thorough! Nice work. +rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Python Tutorial - Handling Command Line Arguments
    By ShadenSmith in forum Tutorials
    Replies: 3
    Last Post: 06-29-2009, 09:15 PM
  2. VB vs VB.Net
    By Patrick in forum Visual Basic Programming
    Replies: 2
    Last Post: 10-14-2007, 11:58 AM
  3. VB.Net & VB 6.0 Syntax's
    By travy92 in forum Visual Basic Programming
    Replies: 10
    Last Post: 09-20-2007, 04:34 PM
  4. Need a program created in VB.Net
    By Thomas in forum MarketPlace
    Replies: 0
    Last Post: 08-29-2007, 06:02 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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