VB.Net Tutorial/Development/Command Line
Версия от 16:40, 26 мая 2010; (обсуждение)
Determine whether command line arguments are present
Option Strict On
Public Module CommandTest
Public Sub Main()
Dim arguments As String = Command
If arguments = String.Empty Then
Console.WriteLine("An empty string.")
Else
" handle command line argument(s)
Console.WriteLine("Command line: {0}", arguments)
End If
End Sub
End Module
An empty string.
Get the command line arguments using the Sub Main array
Module Module1
Sub Main(ByVal cmdArgs() As String)
Dim strArg As String
If cmdArgs.Length > 0 Then
For Each strArg In cmdArgs
Select Case strArg.Substring(0, 3)
Case "/a1"
Console.WriteLine("Processing arg1: Value is {0}.", _
strArg.Substring(3, strArg.Length - 3))
Case "/a2"
Console.WriteLine("Processing arg1: Value is {0}.", _
strArg.Substring(3, strArg.Length - 3))
End Select
Next strArg
End If
End Sub
End Module