I need to validate a date entered into a textbox in the form mm/dd/yy by using a massive compound IF statement. If the date is valid, nothing happens but if an invalid date is entered, a message box pops up saying, "invalid date."
this is what I have so far:
I've tried a lot of different things to do the leapyear and non leapyear calculations but nothing works.
I can make it work using mod operators but we can't use them.
this is what I have so far:
Visual Basic:
fulldate= txtdate.text
month = fulldate.Substring(0, 2)
day = fulldate.Substring(3, 2)
year = fulldate.Substring(6, 2)
If (month < 1 Or month > 12) Or (day < 1 Or day > 31) Or (year > 3 And year < 38) Or (month = 4 And day > 30) Or (month = 6 And day > 30) Or (month = 9 And day > 30) Or (month = 11 And day > 30) Then
MsgBox("Invalid Date Entered", , "Data Entry Error")
Exit Sub
End If
I've tried a lot of different things to do the leapyear and non leapyear calculations but nothing works.
I can make it work using mod operators but we can't use them.
Last edited: