Whats wrong with my code? Can someone help me plz?
Im using microsoft visual studio and im making a calculator for a project but Im missing somethings. Can someone review and help me in detail?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace calculator2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D1.Text;
}
protected void D2_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D2.Text;
}
protected void D3_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D3.Text;
}
protected void D4_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D4.Text;
}
protected void D5_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D5.Text;
}
protected void D6_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D6.Text;
}
protected void Button7_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D7.Text;
}
protected void D8_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D8.Text;
}
protected void Button9_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D9.Text;
}
protected void Bminus_Click(object sender, EventArgs e)
{
string fnum = TextBox1.Text;
TextBox1.Text = "";
string operation = "subtraction";
}
protected void D0_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + D0.Text;
}
protected void Button12_Click(object sender, EventArgs e)
{
string fnum = TextBox1.Text;
TextBox1.Text = "";
string operation = "addition";
}
protected void Bmult_Click(object sender, EventArgs e)
{
string fnum = TextBox1.Text;
TextBox1.Text = "";
string operation = "multiply";
}
protected void Bclear_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
}
protected void Benter_Click(object sender, EventArgs e)
{
string anum = TextBox1.Text;
int Benter = Convert.ToInt16(anum);
int snum = Convert.ToInt16(fnum);
}
}
}
Re: Whats wrong with my code? Can someone help me plz?
First thing you will need is to go back and put your code in code tags
Second, please specify any errors you are getting or the specific problem you are facing.
Re: Whats wrong with my code? Can someone help me plz?
"fnum" is defined inside the scope of the button clicks, but then you try to use it outside of that scope.