Filtering non numeric charactors
-
Hi, I want to filter non numeric characters in one of my text boxes (windows form). I used following code for that. ________________________________________________________________________________________________ if ((e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) || (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) || (e.KeyCode == Keys.Back) || ((e.KeyCode == Keys.Oemcomma || e.KeyCode == Keys.OemPeriod || (e.KeyCode == Keys.Decimal)) && (txtNetAssetValue.Text.IndexOf(",") == -1 && txtNetAssetValue.Text.IndexOf(".") == -1))) ________________________________________________________________________________________________ I could filter all the non-numeric characters except "!@#$%^&*()_+" . Can you tell me the group they belonging? Thanks!!!:)
jayasshc
-
Hi, I want to filter non numeric characters in one of my text boxes (windows form). I used following code for that. ________________________________________________________________________________________________ if ((e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) || (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) || (e.KeyCode == Keys.Back) || ((e.KeyCode == Keys.Oemcomma || e.KeyCode == Keys.OemPeriod || (e.KeyCode == Keys.Decimal)) && (txtNetAssetValue.Text.IndexOf(",") == -1 && txtNetAssetValue.Text.IndexOf(".") == -1))) ________________________________________________________________________________________________ I could filter all the non-numeric characters except "!@#$%^&*()_+" . Can you tell me the group they belonging? Thanks!!!:)
jayasshc
try Char.IsNumeric and Char.IsControl and then add your check for decimal characters.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )