Hi guys,

I have developed this quite basic calculator based on windows forms and I was wondering whether there is a way to block any user input that is not a number. I am using two TextBoxes for getting the user input, then converting those string values into doubles for the calculations and then with the use of switch I am choosing the operator for the calculations.

I would really like to filter the user input but I am having a hard time to do that since the string TextBoxes can receive any type of input. Certainly, if the user enters a string, the calculation cannot be performed and the program crashes.

Thank you in advance.

Kind Regards,

croussou

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.