I have searched here and google but I am still confused as to how to make this work. I have an application that will be run automaticly from a server by ActiveBatch. This app will run a report for 1 of 3 date ranges depending on the parameter passed into it from ActiveBatch. My problem is I don't understand how to use CommandLineArgs to accomplish this. Could someone please explain to me how CommandLineArgs works? The code I have so far is below...
Dim runType As String
Dim numComArgs As String
numComArgs = My.Application.CommandLineArgs.Count
'---Log the program is beginning and the initial parameters
ArgLogFile = New Log("\\kronos\ProdReptACD\Logs\ArgLogFile.log")
ArgLogFile.Write("Command Arguments: " & My.Application.CommandLineArgs.Count.ToString())
For index As Integer = 0 To (My.Application.CommandLineArgs.Count - 1)
LogFile.Write(vbTab & index.ToString & "-" & My.Application.CommandLineArgs(index).ToString())
Next
'---Set the Run Type to the value of the first parameter passed in.
'---If no parameter was passed, then default to weekly
If numComArgs = 0 Then
runType = "Weekly"
Else
runType = My.Application.CommandLineArgs(numComArgs - 1).ToString()
End If
If UCase(runType) = "WEEKLY" Then
dtStart = DateAdd("d", -6 - Weekday(Now()), Now())
dtEnd = DateAdd("d", -Weekday(Now()), Now())
ElseIf UCase(runType) = "CALENDAR" Then
dtStart = "01/01/" & Year(Now()) - 1
dtEnd = "12/31/" & Year(Now()) - 1
ElseIf UCase(runType) = "FISCAL" Then
If Month(Now()) > 6 Then
dtStart = "07/01/" & Year(Now()) - 1
dtEnd = "06/30/" & Year(Now())
Else
dtStart = "07/01/" & Year(Now()) - 2
dtEnd = "06/30/" & Year(Now()) - 1
End If
End If
Dim runType As String
Dim numComArgs As String
numComArgs = My.Application.CommandLineArgs.Count
'---Log the program is beginning and the initial parameters
ArgLogFile = New Log("\\kronos\ProdReptACD\Logs\ArgLogFile.log")
ArgLogFile.Write("Command Arguments: " & My.Application.CommandLineArgs.Count.ToString())
For index As Integer = 0 To (My.Application.CommandLineArgs.Count - 1)
LogFile.Write(vbTab & index.ToString & "-" & My.Application.CommandLineArgs(index).ToString())
Next
'---Set the Run Type to the value of the first parameter passed in.
'---If no parameter was passed, then default to weekly
If numComArgs = 0 Then
runType = "Weekly"
Else
runType = My.Application.CommandLineArgs(numComArgs - 1).ToString()
End If
If UCase(runType) = "WEEKLY" Then
dtStart = DateAdd("d", -6 - Weekday(Now()), Now())
dtEnd = DateAdd("d", -Weekday(Now()), Now())
ElseIf UCase(runType) = "CALENDAR" Then
dtStart = "01/01/" & Year(Now()) - 1
dtEnd = "12/31/" & Year(Now()) - 1
ElseIf UCase(runType) = "FISCAL" Then
If Month(Now()) > 6 Then
dtStart = "07/01/" & Year(Now()) - 1
dtEnd = "06/30/" & Year(Now())
Else
dtStart = "07/01/" & Year(Now()) - 2
dtEnd = "06/30/" & Year(Now()) - 1
End If
End If