private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            char c = e.KeyChar;
            //c == 8 is Backspace
            //c == 32 is Space
            //c == 13 is Carriage return (Enter)
            // http://www.asciitable.com/ Tabel of ascii characters
            if ((Char.IsDigit(c) || c == 8) || c == 32 || c == 13) return; 
            e.Handled = true; //
        }

For a numbers with decimal point you add c == 46 and for negative numbers use c == 45

If I do that, then -384.2834-234.20394 becomes acceptable, and that isn't a number!

And why are you using the magic numbers rather than the Keys enumeration.

Edited 4 Years Ago by Momerath