|
-
Mar 26th, 2003, 05:11 PM
#1
Thread Starter
Junior Member
Format question*resolved*
i need to verify if a string is in the correct format for a telephone number, ie: "(###)###-####" ... i could do it w/ many if then's, but i'd rather not. can anyone think of an easier way to check the format..theres no format(phonenumber) =(... i had a loop that would check to make sure theres a number in every location other than 1,5,9..but if someone put "(###P###-####" it wouldn't find that as an error...
Last edited by VBnewbie2002; Mar 26th, 2003 at 05:26 PM.
-
Mar 26th, 2003, 05:23 PM
#2
Possibly something like:
VB Code:
Dim sbuff As String
'Example 1
sbuff = "(123)456-7890"
If sbuff Like "(###)###-####" Then MsgBox "Phone Number Format"
'Example 2
sbuff = "(123)123[b]P[/b]-7890"
If sbuff Like "(###)###-####" Then MsgBox "Phone Number Format"
-
Mar 26th, 2003, 05:27 PM
#3
Thread Starter
Junior Member
thanks. that worked with little modification for my prog, but ya thanks
-
Mar 26th, 2003, 05:48 PM
#4
NP 
Here's a list of patterns
Characters in pattern Matches in string
? Any single character.
* Zero or more characters.
# Any single digit (0–9).
[charlist] Any single character in charlist.
[!charlist] Any single character not in charlist.
Bruce.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|