MikeBronner
Programmer
What I am trying to do is create a textbox validation routine for dates. This routine should automatically insert the slashes while the user is typing in the dates.
I thought I might try this best using the KeyPress event on the specified textbox, but it doesn't quite seem to work. Here's the code I'm using:
Prtivate Sub txtBox_keyPress(Index As Integer, KeyAscii As Integer)
Select Case (len(txtBox.Text))
Case 0, 2, 3, 5, 6, 7, 8, 9
KeyAscii = KeyAscii
Case 1, 4
KeyAscii = KeyAscii
txtBox.Text = txtBox.Text & "/"
End Select
End Sub
For some reason the function will not insert the "/" correctly, or it will not insert the KeyAscii as desired after the shlash has been inserted (depending on the sequence of statements). Either way, it won't insert a slash after the second and fifth numbers have been typed.
Any ideas? Best Regards and many Thanks!
Michael G. Bronner X-)
"The problem with the world is that everyone is a few drinks behind." Humphrey Bogart
I thought I might try this best using the KeyPress event on the specified textbox, but it doesn't quite seem to work. Here's the code I'm using:
Prtivate Sub txtBox_keyPress(Index As Integer, KeyAscii As Integer)
Select Case (len(txtBox.Text))
Case 0, 2, 3, 5, 6, 7, 8, 9
KeyAscii = KeyAscii
Case 1, 4
KeyAscii = KeyAscii
txtBox.Text = txtBox.Text & "/"
End Select
End Sub
For some reason the function will not insert the "/" correctly, or it will not insert the KeyAscii as desired after the shlash has been inserted (depending on the sequence of statements). Either way, it won't insert a slash after the second and fifth numbers have been typed.
Any ideas? Best Regards and many Thanks!
Michael G. Bronner X-)
"The problem with the world is that everyone is a few drinks behind." Humphrey Bogart