ss002d6252
New member
- Joined
- Jul 3, 2006
- Messages
- 4
- Programming Experience
- Beginner
I have a list box on my form with 2 value - "2010" & "2011"
When I change the value in the listbox it should set the minimum and maximum value of 2 datetimepickers.
Each time I try to change the value I get an error - for example if I change the listbox from 2011 to 2010 I get the error:
"Value of '31/03/2011 00:00:00' is not valid for 'MaxDate'. 'MaxDate' must be greater than or equal to MinDate.
Parameter name: MaxDate"
Any help would be appreciated (I'm back to using vb.net after a couple of years off so I'm a bit rusty to say the least).
When I change the value in the listbox it should set the minimum and maximum value of 2 datetimepickers.
Each time I try to change the value I get an error - for example if I change the listbox from 2011 to 2010 I get the error:
"Value of '31/03/2011 00:00:00' is not valid for 'MaxDate'. 'MaxDate' must be greater than or equal to MinDate.
Parameter name: MaxDate"
Any help would be appreciated (I'm back to using vb.net after a couple of years off so I'm a bit rusty to say the least).
VB.NET:
If ListBox1.SelectedIndex = "0" Then
DateTimePicker1.MaxDate = #3/31/2011#
DateTimePicker1.MinDate = #4/1/2010#
DateTimePicker2.MaxDate = #3/31/2011#
DateTimePicker2.MinDate = #4/1/2010#
End If
If ListBox1.SelectedIndex = "1" Then
DateTimePicker1.MaxDate = #3/31/2012#
DateTimePicker1.MinDate = #4/1/2011#
DateTimePicker2.MaxDate = #3/31/2012#
DateTimePicker2.MinDate = #4/1/2011#
End If