Numeric Data Mask - Using Regular Expressions

Discussion in 'Questions (Windows Mobile)' started by david, Jan 3, 2008.

  1. david

    david Member Licensed User

    Hi Erel,

    I continue to work with Basic4PPc and I think it is wonderful. I am still doing work for a Wasp 3200 barcode device running WM 5.0.

    My latest application is now nearly 3500 lines in length and growing. A big part of the code is devoted to masking text edit fields for numeric data and making sure that the integer and decimal values on any given field do not exceed the limits imposed in the specifications.

    I spoke with a friend who works exclusively in Visual Studion 2005 and he said I could do a numeric mask using Regular Expressions. Although, he thought that might only work on the web side (where he does most of his development).

    I now see that the Regex library does include limited support for Regular Expressions. Before I embark on what could be a fruitless effort, can you tell me if the Regex library would allow me to create numeric data masks as described below, and if so, do you have any sample code other than what is in the help file?

    Additionally, I should mention that I am still working with Version 5.80. I wanted to finish this project before upgrading.

    Thanks for your assistance.

    Regards,

    David Solomon
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What Regular Expressions features are you missing in Regex library?

    You could use the following code to check if a string is a valid number:
    Code:
    Sub App_Start
        
    regex.New1("^[-+]?([0-9]*\.[0-9]+|[0-9]+)$")
        
    Msgbox(regex.IsMatch("2.454")) 'true
        Msgbox(regex.IsMatch("12:43")) 'false
    End Sub
     
  3. david

    david Member Licensed User

    Numeric Data Mask Using Regex

    Hi Erel,

    Thanks for the quick reply (as usual).

    I will give it a try.

    Regards,

    David
     
Loading...