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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Charly O
    New Member
    • Dec 2010
    • 1

    #1

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

    What is the best way to validate a TextBox for Date input using VBA. How to code date inputmask in vba
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Code:
    Private Sub CommandButton1_Click()
       If TextBox1 = vbNullString Then Exit Sub
       If IsDate(TextBox1) Then
         TextBox1 = Format(TextBox1, "Short Date")
       Else
         MsgBox "Non valid date"
         Cancel = True
       End If
    End Sub

    Comment

    Working...