2010-08-15, 03:18 PM
I've been working on a calculator to compare experience per level and cumaltive experience in the three experience curves MapleStory uses. On a KeyPress event for every input box, I call this method.
The idea was to limit the input to numbers, so I wouldn't have to make fancy checks for letters, but a few problems arose.
I need some help with this. I want to limit all the inputs to integers, except for two which I want limited to decimals rounded to the nearest hundredth. How can I do this with Regular Expressions or with another method?
Code:
private void WhenaKeyIsPressed(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
{
e.Handled = true;
}
}- Backspace does not work. To delete something, I have to arrow key behind it and press Delete.
- Decimals do not work. I want it to take a decimal value for percents, but it blocks the "." key too.
I need some help with this. I want to limit all the inputs to integers, except for two which I want limited to decimals rounded to the nearest hundredth. How can I do this with Regular Expressions or with another method?

