我的电脑用的是VSC#2005半的刚刚做的一个简易计算器程序,小数点部分可以重复输入怎么改?还有,bug怎么用?我是初学者各位大虾帮帮忙using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace calculator
{
public partial class frmcalcul : Form
{
public frmcalcul()
{
InitializeComponent();
}
public int Opercode; //声明运算符
public float starter, middle, ender;
public int Count; //点击次数
/// <summary>
/// 分别做加、减、乘、除、取余运算
/// </summary>
public void Calculate()
{
try
{
switch (Opercode)
{
case 1:
ender = starter + middle;
txtInput.Text = ender.ToString();
break;
case 2:
ender = starter - middle;
txtInput.Text = ender.ToString();
break;
case 3:
ender = starter * middle;
txtInput.Text = ender.ToString();
break;
case 4:
if (middle == 0)
{
MessageBox.Show("除数不能为 0 ","有没有搞错?!!");
break;
}
ender = starter / middle;
txtInput.Text = ender.ToString();
break;
case 5:
ender = starter % middle;
txtInput.Text = ender.ToString();
break;
}
}
catch
{
MessageBox.Show("输入错误!","提示");
}
}
/// <summary>
/// 将上次运算结果清空
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frmcalcul_Load(object sender, EventArgs e)
{
}
private void btnRestor_Click(object sender, EventArgs e)
{
txtInput.Text = null;
txtInput.Text = null;
txtInput.Focus();
}
private void btnBack_Click(object sender, EventArgs e)
{
string showNumber;
float tmp;
showNumber = txtInput.Text;
if (txtInput.Text.Length > 1)
{
txtInput.Text = showNumber.Substring(0, showNumber.Length - 1);
tmp = float.Parse(txtInput.Text);
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace calculator
{
public partial class frmcalcul : Form
{
public frmcalcul()
{
InitializeComponent();
}
public int Opercode; //声明运算符
public float starter, middle, ender;
public int Count; //点击次数
/// <summary>
/// 分别做加、减、乘、除、取余运算
/// </summary>
public void Calculate()
{
try
{
switch (Opercode)
{
case 1:
ender = starter + middle;
txtInput.Text = ender.ToString();
break;
case 2:
ender = starter - middle;
txtInput.Text = ender.ToString();
break;
case 3:
ender = starter * middle;
txtInput.Text = ender.ToString();
break;
case 4:
if (middle == 0)
{
MessageBox.Show("除数不能为 0 ","有没有搞错?!!");
break;
}
ender = starter / middle;
txtInput.Text = ender.ToString();
break;
case 5:
ender = starter % middle;
txtInput.Text = ender.ToString();
break;
}
}
catch
{
MessageBox.Show("输入错误!","提示");
}
}
/// <summary>
/// 将上次运算结果清空
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frmcalcul_Load(object sender, EventArgs e)
{
}
private void btnRestor_Click(object sender, EventArgs e)
{
txtInput.Text = null;
txtInput.Text = null;
txtInput.Focus();
}
private void btnBack_Click(object sender, EventArgs e)
{
string showNumber;
float tmp;
showNumber = txtInput.Text;
if (txtInput.Text.Length > 1)
{
txtInput.Text = showNumber.Substring(0, showNumber.Length - 1);
tmp = float.Parse(txtInput.Text);