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 program's command-line arguments
Keywordslist, command line, command, arguments
CategoriesTips and Tricks, Windows
 
Use the Command$ function.

When you start a program by dragging files onto it in Windows Explorer or onto a shortcut to the program, the files are listed by the Command$ function.

Instructions:

Build the program into an executable. Then drag files onto the exe file in Windows Explorer.

 
Private Sub Form_Load()
    ' Display the command line parameters.
    parameters = Command$
    Do While Len(parameters) > 0
        pos = InStr(parameters, " ")
        If pos = 0 Then
            new_parameter = parameters
            parameters = ""
        Else
            new_parameter = Left$(parameters, pos - 1)
            parameters = Mid$(parameters, pos + 1)
        End If
        txt = txt & new_parameter & vbCrLf
    Loop

    Text1.Text = txt
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated