Private mstrCmdLineAs String'Holds the command line arguments
Public Sub Main() 'Load Command Line Arguments mstrCmdLine = Command End Sub Private Function GetSwitchValue(ByVal Switch As String, _ Optional ByVal Delimiter As String = " ", _ Optional ByVal DefaultValue As String = "") As String Dim strResults()As String Dim lngLoop As Long Dim lngUpperAs Long Dim strResultAs String On Error Goto GetSwitchValue_Error strResult = DefaultValue strResults = Split(mstrCmdLine, Delimiter) lngUpper = UBound(strResults) If lngUpper < 1 Then Goto GetSwitchValue_Exit For lngLoop = 0 To lngUpper - 1 If strResults(lngLoop) = Switch Then strResult = strResults(lngLoop + 1) Exit For End If Next lngLoop Goto GetSwitchValue_Exit GetSwitchValue_Error: 'Write To Log File 'WriteToLog "GetSwitchValue_Error: " & Err.Number & " " & Err.Description Err.Clear GetSwitchValue_Exit: On Error Goto 0 GetSwitchValue = strResult End Function Inputs: Input: SwitchAs String ... Switch to find Delimiter As String ... Command Line Delimiter Returns: Output: GetSwitchValue As String ... Switch Value, or Empty String if not found Assumes: This code requires that you have a Module level variable to hold the command line argument called mstrCmdLine |