Passing arguments to your VB.NET console application
Posted by Daniel - 2,802 Views
A console application or a command line interface or CLI is a method of interacting with a computer via a text terminal. Commands are entered as lines of text (that is, sequences of typed characters) from a keyboard, and output is also received as text -wikipedia.org
To create a new console application project with Visual Basic.NET, choose File - New - Project. On the next dialog that appears, select Visual Basic Projects from the Project Types treeview then select Console Application icon from the Templates listview. Fill the project detail such as name and location then hit OK. A new module named Module1 will be created after that.
Inside the newly created module, there is a Sub procedure called Main(). This is the startup object of your console application, where you write your program code.
We will create a simple VB.NET console application which may accepts CLI parameters separated by commas. Below is the line that initiated an array to hold the parameters passed to the application:
Lets say the name of your application is “myApp”. If you run it with this syntax below:
Then the arrArgs array will contains these element:
arrArgs(1) = "World"
What you are going to do next with those values is up to you. Following is the Sub Main() full code you can use to test it:
Dim arrArgs() A s String = Command.Split(“,”)
Dim i As Integer
Console.Write(vbNewLine & vbNewLine)
If arrArgs(0) <> Nothing Then
For i = LBound(arrArgs) To UBound(arrArgs)
Console.Write(“Parameter “ & i & ” is “ & arrArgs(i) & vbNewLine)
Next
Else
Console.Write(“No parameter passed”)
End If
Console.Write(vbNewLine & vbNewLine)
End Sub
That code will accept parrameters passed to the EXE then it will display the accepted parameters to the monitor.
__________________________
The following posts are programmatically considered as related to the current post by YARPP Plugin:
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
- How to Get User Input and allowing more than 256 characters to be entered on .NET Console Application
- Runtime-Form-Creation. Automatically creating child forms in a Delphi MDI application with a component array
- Visual Basic.NET, an example of using HTTPWebRequest object
- Resizing image on the fly with ASP.NET using the System.Drawing namespace
Related posts brought to you by Yet Another Related Posts Plugin.
Latest from Programming
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- SmartImageResizer Plugin, WordPress plugin based on Joe Lencioni’s Smart Image Resizer
- Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup
- Free Softwares to help you learn Regular Expression or to enhance your RegEx skill
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
Leave a Reply
Latest Blog Entries
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- The Lack of Chances is the Source of Poverty, Can we make a different?
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
- TCPView for Windows, Tool to check TCP and UDP Connections on your system
- SmartImageResizer Plugin, WordPress plugin based on Joe Lencioni’s Smart Image Resizer
- Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup
Categories
Neighbours and Friends
Login Here
Comments - Thanks Guys :)
Coarveadvexon: As the call, so the echo :D Coarveadvexon’s last blog post: Ford Kuga 2.5 Turbo
Chat: nice thank you very much for this article.
a_suliman: thanx for every thing
Miss Lunatic: Jaja, it’s a yolk. Thanks for the compliment ;) Miss Lunatic’s last blog post: Pitas y guacamole
Miss Lunatic: Thank you! Your style css is awesome. I’m going to start customizing with it. Thank you :D Miss Lunatic’s last blog...
Most Popular Entries
- Passing arguments to your VB.NET console application
- ASCII To PDU Converter (Convert ASCII to PDU and vice versa)
- An example: Using CPort Delphi Component to read data from your cellphone
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
- Replacing and filtering text with regular expression using Delphi, Visual Basic and ASP
Software Collections
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
- TCPView for Windows, Tool to check TCP and UDP Connections on your system
- The Code Snippet Plugin, my favourite syntax highlighter plugin for WordPress
- ContuttoPDF (Wordpress Plugin to convert your Content to PDF)
Blogging Related Stuff
- Change the WordPress permalink structure to the best format, and yes it’s a little bit scary :D
- Something is wrong, the Google Search Result from my blog looks bad, don’t laugh please :D
- Several tips to reduce Blog Noise, especially when your blog covers more than one niche
- How to remove your indexed pages or even your entire site from Google and Yahoo!

















