I started learning winform and made a calculator,
(Haha, it's very simple ....)
Implementation: Four arithmetic operations of two floating point numbers. The input is incorrect because it is input by the keyboard (for example, the input character)
Calculation Result:
Code:
-
- Private VoidSub_click (ObjectSender, eventargs E)// Subtraction
-
- {
-
- If(Checkin ())
- {
-
- Label4.text =String. Format ("{0}-{1 }={ 2 }", Textbox1.text, textbox2.text ,(Double. Parse (textbox1.text ))-(Double. Parse (textbox2.text )));
-
- }
-
- Else
- {
-
- }
-
- }
-
Code:
-
- Private BoolCheckin ()// Input DetectionCodeHowever, it is more convenient to use tryparas, just forget how to use it, and write it by yourself.
-
- {
- Try
-
- {
-
- Convert. todouble (textbox1.text );
-
- Convert. todouble (textbox2.text );
-
- Return True;
- }
-
- Catch(Exception E)
-
- {
-
- Label4.text =String. Format ("{0} enter a number", E. Message );
-
- Return False;
- }
-
- }
(At the beginning, you can do a simple job... it seems that the coordinates are used for the built-in calculator in windows? Continue to work ......
Check error: