最近在学c# 从网上下了一份计算机的源程序研究 其中关于输入问题 比如0-9 网上的各位高手都是直接用一个函数就搞定了。。比如
private void num_click(object sender, EventArgs e)
{
Button b = (Button)sender;
if (dit >= 1 && b.Text == ".") { return; }
if (dit < 1 && textBox1.Text.Length > 0 && textBox1.Text[textBox1.Text.Length - 1] == '.') {
textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
}
if (b.Text == ".") { dit++; }
if (!add) { textBox1.Text = ""; add = true;}
textBox1.AppendText(b.Text);
if (textBox1.Text == ".") textBox1.Text = "0.";
if (dit < 1 && textBox1.Text != "0.") textBox1.AppendText(".");
}
那位高手能告诉我如何实现的嘛。。
private void num_click(object sender, EventArgs e)
{
Button b = (Button)sender;
if (dit >= 1 && b.Text == ".") { return; }
if (dit < 1 && textBox1.Text.Length > 0 && textBox1.Text[textBox1.Text.Length - 1] == '.') {
textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
}
if (b.Text == ".") { dit++; }
if (!add) { textBox1.Text = ""; add = true;}
textBox1.AppendText(b.Text);
if (textBox1.Text == ".") textBox1.Text = "0.";
if (dit < 1 && textBox1.Text != "0.") textBox1.AppendText(".");
}
那位高手能告诉我如何实现的嘛。。
感觉像是计算器