Retrieve Command-Line Parameters

Problem

You need to retrieve the command-line parameters that are used to execute your application.

Solution

Create a Main subroutine that accepts an array of strings. This array will be automatically populated with all command-line arguments.

Discussion

Command-line arguments are most commonly used in Console applications. In fact, many Console utilities require command-line parameters to supply a minimum amount of information. Command-line arguments are often used in document-based Windows-based applications to quickly open specific files. For example, the command winword.exe mydoc.doc could be used to launch Microsoft Word and open the mydoc.doc file in one operation.

To retrieve command-line arguments in a Windows ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.