00shoe
Member
- Joined
- Oct 12, 2006
- Messages
- 20
- Programming Experience
- 3-5
Hey,
I want to make a dtp that only allow users to select dates that are weekdays.
I have written the following bit of code:
Private Sub dtpPH_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpPH.ValueChanged
However there is a problem with the code, as when a user clicks on a date that has a day of the week of saturday or sunday, the msgbox appears twice for them. (I think it’s got to do with the ValueChanged Handler).
Is there a way either:
1) Disable the user from selecting saturday or sunday.
-- or --
2) Have the msgbox only display once.
Thanks.
I want to make a dtp that only allow users to select dates that are weekdays.
I have written the following bit of code:
Private Sub dtpPH_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpPH.ValueChanged
Dim strDOW AsString = dtpPH.Value.DayOfWeek
If strDOW = DayOfWeek.Saturday Then
dtpPH.Value = dtpPH.Value.Subtract(System.TimeSpan.FromDays(1))
MsgBox("A Public Holiday Cannot Be On A Saturday. ", MsgBoxStyle.Exclamation, "Saturday cannot be PH")
ElseIf strDOW = DayOfWeek.Sunday Then
End SubdtpPH.Value = dtpPH.Value.Add(System.TimeSpan.FromDays(1))
MsgBox("A Public Holiday Cannot Be On A Sunday. ", MsgBoxStyle.Exclamation, "Sunday cannot be PH")
EndIf
However there is a problem with the code, as when a user clicks on a date that has a day of the week of saturday or sunday, the msgbox appears twice for them. (I think it’s got to do with the ValueChanged Handler).
Is there a way either:
1) Disable the user from selecting saturday or sunday.
-- or --
2) Have the msgbox only display once.
Thanks.