Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is it possible to validate date in Visual Basic Editor? If so how.
I am trying to set up a validation method for a text box in Visual Basic
Editor. I need to validate the cell so that it is 11 digits long and only contains numbers, if possible it must have a 0 at the beginning, though this is not compulsory. This validation is for a telephone number, but i have not found any way to validate the box apart from maximum text length. Any help would be appreciated a lot, thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is it possible to validate date in Visual Basic Editor? If so how.
Matt,
Try this Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) With TextBox1 If Len(.Text) = 11 Then KeyAscii = 0 ElseIf Len(.Text) = 0 Then If KeyAscii < 48 Then KeyAscii = 0 End If ElseIf Not IsNumeric(Asc(KeyAscii)) Then KeyAscii = 0 End If End With End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Matt" wrote in message ... I am trying to set up a validation method for a text box in Visual Basic Editor. I need to validate the cell so that it is 11 digits long and only contains numbers, if possible it must have a 0 at the beginning, though this is not compulsory. This validation is for a telephone number, but i have not found any way to validate the box apart from maximum text length. Any help would be appreciated a lot, thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic Editor | Excel Discussion (Misc queries) | |||
Password in Visual basic editor | Excel Worksheet Functions | |||
Visual Basic Editor - Time and Date Entry Continued | Excel Worksheet Functions | |||
Visual Basic Editor opens bi itself | Excel Discussion (Misc queries) | |||
Visual basic editor | Excel Discussion (Misc queries) |