using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _
{
public partial class calculator : Form
{
bool plus = false;
bool equal = false;
bool minus = false;
public calculator()
{
InitializeComponent();
}
private void bt1_Click(object sender, EventArgs e)
{
this.output.Text += "1";
}
private void bt2_Click(object sender, EventArgs e)
{
this.output.Text += "2";
}
private void bt7_Click(object sender, EventArgs e)
{
this.output.Text += "7";
}
private void bt3_Click(object sender, EventArgs e)
{
this.output.Text += "3";
}
private void bt4_Click(object sender, EventArgs e)
{
this.output.Text += "4";
}
private void bt5_Click(object sender, EventArgs e)
{
this.output.Text += "5";
}
private void bt6_Click(object sender, EventArgs e)
{
this.output.Text += "6";
}
private void bt8_Click(object sender, EventArgs e)
{
this.output.Text += "8";
}
private void bt9_Click(object sender, EventArgs e)
{
this.output.Text += "9";
}
private void bt0_Click(object sender, EventArgs e)
{
this.output.Text += "0";
}
private void btplus_Click(object sender, EventArgs e)
{
if (output.Text == "")
{
return;
}
else
{
plus = true;
output.Tag = output.Text;
output.Text = "";
}}
private void btminus_Click(object sender, EventArgs e)
{
if (output.Text == "")
{
return;
}
else
{
minus = true;
output.Tag = output.Text;
output.Text = "";
}
}
private void btequal_Click(object sender, EventArgs e)
{
equal = true;
if (plus)
{
decimal dec = Convert.ToDecimal(output.Tag) + Convert.ToDecimal(output.Text);
output.Text = dec.ToString();
}
else if (minus)
{
decimal dec = Convert.ToDecimal(output.Tag) - Convert.ToDecimal(output.Text);
output.Text = dec.ToString();
}
}
}
}
now I am new to the try catch clause, and I need to add some specifically to catch non -integral numbers and non-number characters
now what exactly does a catch clause do, like specifically where should I put it, at the end right? and how should the code look give or take, just some basics to help me finish up this calculator
thanks guys

New Topic/Question
Reply




MultiQuote




|