Results 1 to 6 of 6

Thread: [RESOLVED] masked textbox

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    Resolved [RESOLVED] masked textbox

    i have a masked text box for phone numbers. i want to save the results as a double but it includes the parenthesis and dashes. what would be the best way to remove the mask and save only the numbers?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: masked textbox

    try this:

    vb Code:
    1. MaskedTextBox1.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals
    2. MsgBox(MaskedTextBox1.Text)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: masked textbox

    Phone numbers should not be saved as numbers. They should be saved as text because that's what they are. Do you ever plan to add or subtract two phone numbers?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    Re: masked textbox

    good point i guess but does it really matter? it is all numbers so wouldn't it be logical to store it as a number?

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: masked textbox

    not if it begins with a zero. it'll be truncated

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    Re: masked textbox

    good point. ah well then that settles it. i will store it as text. thanks.

    now the question is should i save it with the mask or not?
    Last edited by bezaman; Mar 8th, 2010 at 08:08 PM.

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