Site Search:
Sign in | Join | Help
4Penny.net

VB.NET

Notes, Tricks and Tips on VB.NET

Processing arguments in a VB.NET console app

Here is a VB.NET class that shows how to process arguments for a console app

Create a console app, and in the project properties click on DEBUG, then specify something in the 'Commant Line Arguments' area. For the sample app, you might put 'olap diskspace' and those two items will be processed.

 Once you build and deploy the app, you would call the app like this: MYAPP.EXE OLAP DISKSPACE, where OLAP and DISKSPACE are my example arguments

Module Module1


    Sub Main(ByVal args() As String)
        'can be called with three args:
        'OLAP - runs the olap scrips
        'DISKSPACE - checks the disk space
        'BACKUP - runs a file copy routine


        Dim a As Int16
        If args.Length = 0 Then
            Exit Sub
        End If


        For a = 0 To args.Length - 1
            Select Case args(a).ToUpper
                Case "OLAP"
                    processOLAP()
                Case "DISKSPACE"
                    processDISKSPACE()
                Case "BACKUP"
                    processDISKSPACE()
            End Select


        Next



    End Sub
    Sub processOLAP()


    End Sub
    Sub processDISKSPACE()


    End Sub
    Sub processBACKUP()


    End Sub
End Module

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.