What's Here?
- Members: 148,730
- Replies: 504,852
- Topics: 79,500
- Snippets: 2,661
- Tutorials: 705
- Total Online: 1,797
- Members: 82
- Guests: 1,715
|
isual Basic provides only the Number Format Option in DataFormat Property of a Text Box. Using the "Number" option allows people to type negative numbers and numbers with decimals.So here is the code that you should insert in the Text Box's KeyPress Function so that the text-box will accept only phone-numbers.
|
Submitted By: born2c0de
|
|
Rating:
|
|
Views: 16,147 |
Language: Visual Basic
|
|
Last Modified: March 16, 2005 |
Snippet
' Assuming that Text1 is the Text Box where you want the 'user to enter the telephone number, here is the KeyPress 'Event Function that does the trick.
' -Sanchit Karve
' born2c0de@hotmail.com
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Len(Text1.Text) = 0 And KeyAscii = 45 Then
KeyAscii = 0
End If
If KeyAscii >= 58 Or (KeyAscii <= 47 And KeyAscii <> 45 And KeyAscii <> 8 And KeyAscii <> 13) Then
KeyAscii = 0
End If
End Sub
Copy & Paste
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|