chadmanvb
asked on
Get months and year from a combobox and put in a list
I have a 2 comboboxes that contain a month, year. I need to get a range of the months/years between the 2 combobox's.
combobox1=May,2013
combobox2=August,2013
So I would like a set a variable in a list that contains these dates in a date format.
Something like
Dim mydates As ArrayList
mydates.Add("May" & "2013")
mydates.Add("June" & "2013")
mydates.Add("July" & "2013")
mydates.Add("August" & "2013")
I just need these in a date format so I can use them late in a date function. I'm not sure how to calculate the range to put into the list.
combobox1=May,2013
combobox2=August,2013
So I would like a set a variable in a list that contains these dates in a date format.
Something like
Dim mydates As ArrayList
mydates.Add("May" & "2013")
mydates.Add("June" & "2013")
mydates.Add("July" & "2013")
mydates.Add("August" & "2013")
I just need these in a date format so I can use them late in a date function. I'm not sure how to calculate the range to put into the list.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! That worked great.
a) both combos have same date set
b) dates are in continuous ascending order (month by month without skips)
Open in new window
Actually, in this case (when a) and b) are true, or at least b) is true) you can store just combo indexes. When form is loaded, you can get baseDate=DateTime.ParseExaand then use in a date function like
For i=firstComboIndex to secondComboIndex
YourDateFunction(baseDate.
Next
If combos have different date set, you can use
Dim baseDate = New Date(2010,1,1)
combo1Offset = 24 'months - assuming combo1 starts from Jan,2012
combo2Offset = 30 'months - assuming combo2 starts from Jul,2012
For i=firstComboIndex+combo1Of
YourDateFunction(baseDate.
Next