VB.Net/Development/Command Line

Материал из VB Эксперт
Перейти к: навигация, поиск

Deal with Command Line Arguments

Imports System
Imports System.Configuration
Imports System.Resources " Resource readers
Public Class MainClass
    Shared Sub Main(ByVal args As String())
        Dim flag As Boolean = False
        Dim name As String = ""
        Dim number As Integer = 0
        Dim i As Integer
        For i = 0 To args.Length - 1
            Select Case args(i)
                Case "/flag"
                    flag = True
                Case "/name"
                    i += 1
                    name = args(i)
                Case "/number"
                    i += 1
                    number = Integer.Parse(args(i))
                Case Else
                    Console.WriteLine("invalid args!")
                    Exit Sub
            End Select
        Console.WriteLine(flag.ToString(), "Flag")
        Console.WriteLine(name, "Name")
        Console.WriteLine(number.ToString(), "Number")

    End Sub
End Class

Get Command line

Imports System
Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("CommandLine:        " & System.Environment.rumandLine )
   End Sub 
End Class