lehgzil
09-21-2010, 09:08 PM
good day again,
i have this code which checks the value of the textbox if its a date and if so, prints it out on the same textbox as short date. i have it with an error handler which brings a message box allerting the user of miswriting.
what i cant understand and im trying to do is that when the error occured(user typed a non date value) after the message box prompt it returns to the same textbox for reentry.
i had tried removing the first if, the with block and substituting its exit event to change and click event.
vba:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 = vbNullString Then Exit Sub
If IsDate(TextBox1) Then
TextBox1 = Format(TextBox18, "short date")
Else
MsgBox "Non valid date"
Cancel = False
With TextBox1
.Value = vbNullString
End With
End If
End Sub
hoping for some help, thanks
i have this code which checks the value of the textbox if its a date and if so, prints it out on the same textbox as short date. i have it with an error handler which brings a message box allerting the user of miswriting.
what i cant understand and im trying to do is that when the error occured(user typed a non date value) after the message box prompt it returns to the same textbox for reentry.
i had tried removing the first if, the with block and substituting its exit event to change and click event.
vba:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 = vbNullString Then Exit Sub
If IsDate(TextBox1) Then
TextBox1 = Format(TextBox18, "short date")
Else
MsgBox "Non valid date"
Cancel = False
With TextBox1
.Value = vbNullString
End With
End If
End Sub
hoping for some help, thanks