Dim monthsDictionary As New Dictionary(Of String, Date)
monthsDictionary = objDataAccess.Select_Months(_sStart_Date, _sEnd_Date)
'-------------------------------------------------------------------------
'loop thru monthsDictionary Items
'-------------------------------------------------------------------------
Dim kvpCounter As Integer = -1
Dim kvpMax As Integer = monthsDictionary.Count - 1
For Each kvp As KeyValuePair(Of String, Date) In monthsDictionary
kvpCounter += 1
'-------------------------------------------------------------------------
'align dates
'-------------------------------------------------------------------------
Dim Start_Date As Date = kvp.Value
If kvpCounter = 0 Then
Start_Date = Date.Parse(_sStart_Date)
End If
Dim End_Date As Date = Start_Date.AddMonths(1)
End_Date = End_Date.AddDays(-1)
If kvpCounter = kvpMax Then
End_Date = Date.Parse(Me._sEnd_Date)
End If
Public Function Select_Months( _
ByVal Start_DateString As String, _
ByVal End_DateString As String) As Dictionary(Of String, Date)
Dim monthsDictionary As New Dictionary(Of String, Date)
Try
Dim startKey As String = ""
Dim endKey As String = ""
Dim theStart_Date As Date = Date.Parse(Start_DateString)
Dim Start_Date As Date = Date.Parse(Start_DateString)
Dim startDay As Double = Start_Date.Day - 1
Start_Date = Start_Date.AddDays(-startDay)
Dim End_Date As Date = Date.Parse(End_DateString)
Dim allDone As Boolean = False
While Not allDone
If Start_Date > End_Date Then
allDone = True
Else
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- -------------------------------------- ----------
'
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- -------------------------------------- ----------
Dim x As String = Start_Date.ToString("MMM") + "-" + Start_Date.Year.ToString
monthsDictionary.Add(x, Start_Date)
Start_Date = Start_Date.AddMonths(1)
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- -------------------------------------- ----------
'
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- -------------------------------------- ----------
If startKey = "" Then
startKey = x
End If
endKey = x
End If
End While
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- -------------------------------------- ----------
'
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- -------------------------------------- ----------
'monthsDictionary(startKey) = theStart_Date
'monthsDictionary(endKey) = End_Date
Catch ex As Exception
Throw ex
Finally
End Try
Return monthsDictionary
End Function