![]() |
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. |
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. |
All times are GMT +1. The time now is 12:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com