By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

What is the best way to validate a TextBox for Date input using VBA?

P: 1
What is the best way to validate a TextBox for Date input using VBA. How to code date inputmask in vba
Dec 12 '10 #1
Share this Question
Share on Google+
1 Reply


Guido Geurs
Expert 100+
P: 767
Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2.    If TextBox1 = vbNullString Then Exit Sub
  3.    If IsDate(TextBox1) Then
  4.      TextBox1 = Format(TextBox1, "Short Date")
  5.    Else
  6.      MsgBox "Non valid date"
  7.      Cancel = True
  8.    End If
  9. End Sub
Dec 13 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.