if nothing has been entered into the text box, exit the sub and presumably the user can try again. vbNullString is a built-in vb constant which is used to check for any empty string.
I "stole" this format from an old thread.......It has to check if the dateformat is correct in the textbox......does the job perfect.....just for my understanding....what does the first equation do? Don't get this nullstring?
VB:Private Sub txtbRolldate_Exit(ByVal Cancel As MSForms.ReturnBoolean) 'checks if the date is the right format [B]If txtbRolldate = vbNullString Then Exit Sub[/B] If Not IsDate(txtbRolldate) Then MsgBox "Invalid date format. Please use 'dd-mm-yy' only" txtbRolldate = vbNullString Cancel = True Else txtbRolldate = Format(txtbRolldate, "dd-mm-yy") End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)