Results 1 to 4 of 4

Thread: String.Format phone number

  1. #1

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    String.Format phone number

    Hey,

    String.Format("{0###) ###-####}", 1231231234) produces (123) 123-1234

    String.Format("{0###) ###-####}", 123) produces
    () -123

    How can I left align it so that if only 3 digits are provided, it returns (123) -

    Thanks,
    Last edited by vbgladiator; Feb 20th, 2009 at 12:57 AM.
    Don't anthropomorphize computers -- they hate it

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: String.Format phone number

    Sorry I am not able to get you..
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: String.Format phone number

    Hello,

    Is this input coming from a textbox, and you are having to put it into the correct format?

    If so, have you thought about using a masked textbox?

    http://msdn.microsoft.com/en-us/libr...edtextbox.aspx

    I think that might makes things a bit easier.

    Hope that helps!!

    Gary

  4. #4
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: String.Format phone number

    i think hes saying how can he fill in the area code first if there are only 3 numbers

    im not sure but one way to cheat might be something like


    if textbox.text.length== 3
    {
    format string one way
    }
    else
    {
    String.Format("{0###) ###-####}", 1231231234)
    }

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