Jump to content

Check out our Community Blogs

Recent Status Updates

  • Photo
      10 Jul

    True or just funny? One day programmers will become obsolete as they make errors and programs don't :D

    Show comments (4)
View All Updates

Developed by TechBiz Xccelerator
- - - - -

Reading Command line arguments in VB.NET


  • Please log in to reply
2 replies to this topic

#1 Vswe


    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 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 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 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