- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
- namespace heima
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (textBox1.Text.Length >= 2)
- {
- string s =textBox1.Text.Substring(0, 1) ;
- Console.Write(textBox1.Text.Substring(1, 1));
- if (textBox1.Text.Substring(0, 1) == "0" && textBox1.Text.Substring(1, 1) == "0")
- {
-
- textBox1.Text = "";
-
- }
- }
-
- }
- private void button1_Click(object sender, EventArgs e)
- {
- decimal i = decimal.Parse(textBox1.Text);
- int j = int.Parse(textBox2.Text);
- switch (comboBox1.SelectedIndex)
- {
- case 0:
- label5.Text = "加法运算结果:" + (i + j);
- break;
- case 1:
- label5.Text = "加法运算结果:" + (i - j);
- break;
- case 2:
- label5.Text = "加法运算结果:" + (i * j);
- break;
- case 3:
- label5.Text = "加法运算结果:" + (i / j);
- break;
-
- }
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (textBox2.Text.Length >= 2)
- {
- string s = textBox2.Text.Substring(0, 1);
- Console.Write(textBox2.Text.Substring(1, 1));
- if (textBox2.Text.Substring(0, 1) == "0" && textBox2.Text.Substring(1, 1) == "0")
- {
- textBox2.Text = "";
- }
- }
- }
- }
- }
复制代码 |