For example I key in tomorrow's date in the dtpBirthdate control, I'm expecting to immediately get 1 as a result in the following code:
However, I'm getting 0 on the first run, and then the correct answer on the next instance of execution ie: pressing Validate button once will return 0, and pressing it again will get 1 (without changing the values on the DateTimePicker).Code:DateDiff(DateInterval.Day, Date.Now.Date, dtpBirthdate.Value.Date)
This is the only one that's bugged in the code (as of now) and it's also affecting the validation process (ie: when user gives the correct value, they'd have to validate another time to pass the validation) and the error provider. Anyone have any ideas?
Code:Private Sub InvalidDate() Dim dateErrNIS As String = "" Dim dateErrCOL As String = "" If DateDiff(DateInterval.Day, Date.Now.Date, dtpBirthdate.Value.Date) > 0 Then HighlightError(dtpBirthdate, emDateNow) Else If DateDiff(DateInterval.Day, dtpBirthdate.Value.Date, dtpAdmission.Value.Date) < 0 Then HighlightError(dtpAdmission, emDatePx) Else If DateDiff(DateInterval.Day, dtpAdmission.Value.Date, dtpHAIAcquired.Value.Date) < 1 Then dateErrNIS = dateErrNIS & emDateAdm End If If DateDiff(DateInterval.Day, dtpAdmission.Value.Date, dtpCollection.Value.Date) < 1 Then dateErrCOL = dateErrCOL & emDateAdm End If If DateDiff(DateInterval.Day, dtpBirthdate.Value.Date, dtpHAIAcquired.Value.Date) < 0 Then dateErrNIS = dateErrNIS & emDatePx End If If DateDiff(DateInterval.Day, dtpBirthdate.Value.Date, dtpCollection.Value.Date) < 0 Then dateErrCOL = dateErrCOL & emDatePx End If End If End If If Not dateErrNIS = "" Then HighlightError(dtpHAIAcquired, dateErrNIS) If Not dateErrCOL = "" Then HighlightError(dtpCollection, dateErrCOL) End Sub




Reply With Quote