accepting a parameter on the command line

judge

Member
Joined
Dec 7, 2009
Messages
18
Programming Experience
Beginner
If you have a blank console app, how can you get it to accept the typed word "message" and have a message box appear to say "well done".

Im new to console applications and havebeen studying articles/ebooks for a couple of days, yet i cant find something as simple as this.

Any help is greatly appreciated.

P.S. I can hard code "message" to display a message box saying "hello". But just wandered if it was possible to make it so the user has to physically type "message" onto the command line.

Thanks
 
VB.NET:
Expand Collapse Copy
Dim input As String = Console.ReadLine
If input = "message" Then
    Console.WriteLine(">> you typed ""message""")
End If
Console applications doesn't show message boxes or any other kind of UI other than writing to the console.

edit: I just noticed the thread title says something about command line parameters, if this is what you really meant you can get them from Environment.GetCommandLineArgs function. These are the arguments passed as parameters to the .exe when starting it from command line.
 
Thanks for your help, I have adapted this and used it in my program. I can now accept 3 parameters on the command line.

Thankyou,
Judge
 
Console applications CAN show the legacy MsgBox function, but not the new MessageBox.Show method. Example:

Dim input As String = Console.ReadLine
If input = "message" Then MsgBox("Hello")
 
Of course they can, they can show forms also, you only need to add the reference, but should you? Console applications were not designed for this.
Console class help said:
The console is an operating system window where users interact with the operating system or a text-based console application by entering text input through the computer keyboard, and reading text output from the computer terminal. For example, in Windows the console is called the command prompt window and accepts MS-DOS commands. The Console class provides basic support for applications that read characters from, and write characters to, the console.
 
I knew that. I use mostly console demos in my class but I haven't used the MsgBox. But in another introductory class to computer program structure and logic, the MsgBox and InputBox have been used with console apps for demo purposes.
 
Back
Top