July 22, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

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.

 

 


Sitemap | Contact Us

Rocket Fuel