So, I'm new to C/C++ (a few days, actually) and I'm working on a program that is supposed to calculate the box quality of a subwoofer enclosure (not important)
Here is the code I've been trying that I just copied and pasted. I'm writing the program in Visual C#
private void txtBox_KeyPress(object sender, KeyPressEventArgs e)
//I changed txtBox to the name of the text box I applied it to
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
}
The problem here is that I can still enter letters in the text box. I don't want a message to pop up when I press a letter instead of a number, I just want it to not enter anything if something besides a number or a period is entered into the text box