What's Here?
- Members: 117,613
- Replies: 431,996
- Topics: 66,701
- Snippets: 2,395
- Tutorials: 631
- Total Online: 1,961
- Members: 51
- Guests: 1,910
Who's Online?
|
Welcome to Dream.In.Code |
|
|
Getting VB Help is Easy!
Join 117,613 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 1,961 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
|
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: 14,815 |
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
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|