CokeOrCrack
Board Regular
- Joined
- Dec 13, 2015
- Messages
- 81
- Applicants input their birthdate in a textbox on a userform
- There are numerous formats and errors an individual can make when inputting a birthdate
Questions
- I want the textbox to only allow the input or paste of numbers [0-9] and slashes "/"
- I want the textbox to be formatted as m/d/yyyy
- Is there a way that if an applicant entered "09" the textbox would edit it to "9"?
- Is there a way for the textbox to require the input of two slashes?
- Is there a way to require either one or two values then "/", followed by one or two values then "/" followed by four values?
- Is there a way for dashes "-", periods "." and spaces to be changed to slashes "/"?
Notes
I currently have code that makes it so the textbox only accepts numbers and slashes upon typing, but an individual can still paste any value into the textbox:
Sorry for the multitude of questions, dates require several format checks.
Thanks
OJ
- There are numerous formats and errors an individual can make when inputting a birthdate
Questions
- I want the textbox to only allow the input or paste of numbers [0-9] and slashes "/"
- I want the textbox to be formatted as m/d/yyyy
- Is there a way that if an applicant entered "09" the textbox would edit it to "9"?
- Is there a way for the textbox to require the input of two slashes?
- Is there a way to require either one or two values then "/", followed by one or two values then "/" followed by four values?
- Is there a way for dashes "-", periods "." and spaces to be changed to slashes "/"?
Notes
I currently have code that makes it so the textbox only accepts numbers and slashes upon typing, but an individual can still paste any value into the textbox:
Code:
Private Sub tbBirthdate_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc("/")
Case Else
KeyAscii = 0
End Select
End Sub
Sorry for the multitude of questions, dates require several format checks.
Thanks
OJ