dcsimg
June 20, 2018
Hot Topics:

Windows Secrets for Visual Basic, Part 1

  • January 21, 2003
  • By Karl Moore
  • Send Email »
  • More Articles »

The Power of Command-Line Parameters

Command line parameters can be incredibly useful. They allow users or other applications to pass startup information to your program. For example, if your program was called myapp.exe, they might run the following:

myapp.exe /nodialogs

Here, we have one command line parameter, "/nodialogs". In VB6, we could read this using the Command property. In VB.NET, this has been replaced with the System.Environment.GetCommandLineArgs function, which returns an array of the passed parameters.

And here's a chunk of code to show you just how to read them:

Dim MyStartupArguments()As String, 

intCount As Integer
MyStartupArguments = System.Environment.GetCommandLineArgs

For intCount = 0 To 

UBound(MyStartupArguments)
    MessageBox.Show(MyStartupArguments(intCount).ToString)
Next

Next Time...

Coming up in part two of Windows Secrets, learn how to:

  • Extract HTML from the RichTextBox control
  • Create applications that accept drag-and-drops from Windows Explorer
  • Capture the screen, quick and easy
  • Use the .NET equivalent of PrevInstance.

See you then!

About the Author

Karl Moore is a technology author living in Yorkshire, England. He runs his own consultancy group, White Cliff Computing Ltd, and is author of two best-selling books exposing the secrets behind Visual Basic .NET. When he's not writing for magazines, speaking at conferences, or making embarrassing mistakes on live radio, Karl enjoys a complete lack of a social life. You can visit Karl on the Web at www.karlmoore.com.

# # #





Page 5 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date