I am trying to write a program to check whether or not a CreditCardDate, expressed as 0204 where the first 2 digits are the month and the last 2 are the year, has expired. The following only works if the card month is less than the current month. It doesn't however recognize that 12/01 is < Now. ExpDate, Next Month and Now all print correctly so I am at a loss regarding the logic. Any help most welcome.
Private Sub CheckDate_Click()
Dim NextMonth As Date
Dim ExpDate As Date
ExpDate = Format$(CreditCardDate, "m/YY"
NextMonth = DateAdd("m", 1, ExpDate)
If NextMonth < Now Then
MsgBox "Expired Card"
Print ExpDate
Print NextMonth
Print Now
End If
End Sub
Private Sub CheckDate_Click()
Dim NextMonth As Date
Dim ExpDate As Date
ExpDate = Format$(CreditCardDate, "m/YY"
NextMonth = DateAdd("m", 1, ExpDate)
If NextMonth < Now Then
MsgBox "Expired Card"
Print ExpDate
Print NextMonth
Print Now
End If
End Sub