What do you mean by "trap"? Please clarify (n/t)
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yy")
I use this in the TextBox "Exit" handler, but you can put it where you want...
Any help?
Cory
Re: What do you mean by "trap"? Please clarify (n/t)
I am trying to keep the data entered in 2 text boxes consistent with the format (mm/dd/yy) so that VB can do a calculation of the number of days between the two dates (txt1.value - txt2.value). I get debug errors when I enter a letter though...
does this sound like something I need to do w/trapping?
-Chris
If Len(TextBox1.Text) < 1 Then Exit Sub
If Asc(Right(TextBox1.Text, 1)) < 48 Or _
Asc(Right(TextBox1.Text, 1)) > 57 Then
TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
End If
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yy")
The first part won't allow the user to enter anything but a number. The 2nd part formats it as a date in the format you need...
That do it?
Cory