CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    1

    Question 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);


    }




    }
    }

  2. #2
    Join Date
    May 2007
    Location
    Denmark
    Posts
    623

    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.
    It's not a bug, it's a feature!

  3. #3
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured