Data in Masked Edit Text Boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mwcapps
    New Member
    • Mar 2009
    • 16

    Data in Masked Edit Text Boxes

    I have unformatted text in my SQL 2005 database. I'm pulling it into a masked edit text box with a (999)999-9999 mask. Unfortunately, when I attempt to save the data back it doesn't work because I don't know how to get the 'masked' information back to the 'unmasked' raw data that the database wants.
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Strip out all characters that aren't a number. Either through Regular Expressions, or brute force checking each character in the string.

    Comment

    • mwcapps
      New Member
      • Mar 2009
      • 16

      #3
      Is there any way that you can give me an example of how to accomplish either or both of those solutions. I really appreciate your help.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        I'm not a VB guy (C# spoken here).
        But I can give you my C# function for checking if a string is a number, via RegEx.
        Code:
                // Source Code starts
                /*
                <HowToCompile>
                csc /r:System.Text.RegularExpressions.dll,System.dll Validation.cs 
                </HowToComplie>
                */
                // Function to test for Positive Integers. 
                public static bool IsNaturalNumber(String strNumber)
                {
                    Regex objNotNaturalPattern = new Regex("[^0-9]");
                    Regex objNaturalPattern = new Regex("0*[1-9][0-9]*");
                    return !objNotNaturalPattern.IsMatch(strNumber) &&
                    objNaturalPattern.IsMatch(strNumber);
                }
        I send one character at a time of my entire string. The function returns true or false. If it is true, then I can add that one character to my final string. If not, I can ignore it

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          See here for an example....

          Comment

          Working...