Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleList a VB .NET program's command-line arguments
Keywordslist, command line, command, arguments, .NET, VB.NET, CmdArgs, Sub Main, Function Main
CategoriesTips 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.

 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated