General discussion

Locked

VB.NET Command line switch

By john ·
I was wondering how I can make my windows application accept command line switches so that it will do different things on startup. Also is there any way, with command line switches, to invoke a class when the program is already running?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by maheshkumarvk In reply to VB.NET Command line switc ...

Hi,
The Command Line switches can be accessed through the Command() function that is available with Microsoft.VisualBasic namespace, which is automatically included when you open a VB.Net application in the VStudio IDE.

I have just written a small code to illustrate this-

Imports System
Imports System.IO
Imports Microsoft.VisualBasic
Module CommandLineSwitch
Sub Main()
Console.Write(Command())
End Sub
End Module

You can test this by compiling in the CommandLine using the command line compiler -
>vbc /target:exe /out:CmdLineSwitch.exe TestCL.vb, where the code is saved as TestCL.vb.

After compiling run in the command line as CmdLineSwitch parameter 1 2
and see the output.

This example can be adopted in your windows application as well.

Hope this will help you.

With Prem and Om
In the Name of Iswara
Mahesh

Collapse -

by john In reply to

Poster rated this answer.
Thank you that is what I was looking for.

Collapse -

by john In reply to VB.NET Command line switc ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums