Why is this code not working?
in the second msgbox i have tested as you can see to print mom and the datepart function.
i get 11 and 11 in the message box.
but i never get the correct messagebox.
both have the value of 11 but the if statement is false still.
Code:
Dim dat
Dim yea
Dim mon
Dim da
yea = Left(UserForm4.TextBox_birthyear, 2)
mon = Mid(UserForm4.TextBox_birthyear, 3, 2)
da = Mid(UserForm4.TextBox_birthyear, 5, 2)
dat = DateSerial(yea, mon, da)
If DatePart("m", Date) = mon Then
MsgBox "correct"
Else
MsgBox "incorrect" & mon & " " & DatePart("m", Date)
End If
in the second msgbox i have tested as you can see to print mom and the datepart function.
i get 11 and 11 in the message box.
but i never get the correct messagebox.
both have the value of 11 but the if statement is false still.