Results 1 to 4 of 4

Thread: Format question*resolved*

  1. #1

    Thread Starter
    Junior Member VBnewbie2002's Avatar
    Join Date
    Sep 2002
    Posts
    29

    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.

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Possibly something like:
    VB Code:
    1. Dim sbuff As String
    2.  
    3.  
    4. 'Example 1
    5.  
    6.     sbuff = "(123)456-7890"
    7.    
    8.     If sbuff Like "(###)###-####" Then MsgBox "Phone Number Format"
    9.  
    10.  
    11.  
    12. 'Example 2
    13.  
    14.     sbuff = "(123)123[b]P[/b]-7890"
    15.    
    16.     If sbuff Like "(###)###-####" Then MsgBox "Phone Number Format"

  3. #3

    Thread Starter
    Junior Member VBnewbie2002's Avatar
    Join Date
    Sep 2002
    Posts
    29
    thanks. that worked with little modification for my prog, but ya thanks

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    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
  •  



Click Here to Expand Forum to Full Width