Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Editor Ron Rueter Excel Discussion (Misc queries) 3 October 28th 08 02:48 PM
Password in Visual basic editor Tia[_3_] Excel Worksheet Functions 0 July 11th 08 08:40 AM
Visual Basic Editor - Time and Date Entry Continued Tammy Excel Worksheet Functions 2 January 4th 08 03:49 PM
Visual Basic Editor opens bi itself KG Excel Discussion (Misc queries) 0 September 15th 07 04:02 PM
Visual basic editor Answerfactory Excel Discussion (Misc queries) 3 October 9th 06 09:13 PM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"