|
|
Title | List a VB .NET program's command-line arguments |
Keywords | list, command line, command, arguments, .NET, VB.NET, CmdArgs, Sub Main, Function Main |
Categories | Tips and Tricks, Windows, VB.NET |
|
|
Create a new module named StartupModule and give it a Function Main similar to the following code. This function takes as a parameter an array or strings containing the arguments. It loops through the strings adding them to a ListBox on the main form.
|
|
Module StartupModule
Public Function Main(ByVal CmdArgs() As String) As _
Integer
Dim frm As New Form1()
Dim i As Integer
frm.Text = UBound(CmdArgs) + 1 & " arguments"
For i = 0 To UBound(CmdArgs)
frm.lstCommands.Items.Add(CmdArgs(i))
Next i
frm.ShowDialog()
Return 0
End Function
End Module
|
|
In the Solution Explorer, right click the project name and select Properties. In the Startup Object dropdown, select StartupModule.
Now build the application. If you drag and drop files onto the executable, the program displays the names of the files.
|
|
|
|
|
|