Testing Command Line Arguments For Values

This snippet explains how you can test for command line arguments if they have been executed with the VB.NET application.

' Loop through all the command line arguments given.
For I As Integer = 0 To My.Application.CommandLineArgs.Count - 1
    ' If an argument equals /m
    If My.Application.CommandLineArgs.Item(I) = "/m" Then
        MsgBox("You have used /m!")
    Else ' If it doesn't equal "/m"
        MsgBox("Incorrect CMD Argument.")
    End If
Next

See Also

Dream In Code Submission - http://www.dreamincode.net/code/snippet1442.htm

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License