Discussion Locked

VB.NET Command line switch

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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?

3 replies

by maheshkumarvk

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

This discussion is closed to new replies.