Jump to content

Recent Status Updates

  • Photo
      18 Aug

    When faced with a wall of errors and no hope to fix them, remember the following "Programs always do what you tell them to, and seldom what you want them to, but eventually you'll run out of things that can go wrong and it'll just work. and that's the secret to good programming."

    Show comments (2)
View All Updates

Developed by Kemal Taskin
- - - - -

Reading Command line arguments in VB.NET


  • Please log in to reply
2 replies to this topic

#1 Vswe


    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 05 June 2009 - 04:05 AM

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.

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.

        For i As Integer = 0 To CommandLineArgs.Count - 1

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

Posted Image

Posted Image

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:

Posted Image

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 :D
  • 2

#2 WingedPanther


    A spammer's worst nightmare

  • Moderator
  • 17,006 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 05 June 2009 - 07:23 AM

I like :) +rep
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

#3 Guest_Jordan_*

  • Guest

Posted 06 June 2009 - 05:46 AM

Very thorough! Nice work. +rep
  • 0

Also tagged with one or more of these keywords: VB.NET