using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
   
    public partial class Form1 : Form
    {
        double no1, no2,ans;
       
        void commonEvent(object sender, EventArgs e)       
        {
            Button b = (Button)sender;

            if (b == btn0)
                TextBox1.Text += "0";

            else if (b == btn1)
                TextBox1.Text += "1";

            else if (b == btn2)
                TextBox1.Text += "2";

            else if (b == btn3)
                TextBox1.Text += "3";

            else if (b == btn4)
                TextBox1.Text += "4";

            else if (b == btn5)
                TextBox1.Text += "5";

            else if (b == btn6)
                TextBox1.Text += "6";

            else if (b == btn7)
                TextBox1.Text += "7";

            else if (b == btn8)
                TextBox1.Text += "8";

            else if (b == btn9)
                TextBox1.Text += "9";

            else if (b == btnpls || b == btnmin || b == btnmul || b == btndiv || b == btnmod)
            {
                no1 = double.Parse(TextBox1.Text);
                TextBox1.Text = "";
            }

            else if (b == btnequ)
            {
                no2 = double.Parse(TextBox1.Text);
                ans=no1+no2; 
                TextBox1.Text = ans.ToString;//error ???? y ?? pls explain

            }
        }
       
        public Form1()
        {
            InitializeComponent();
        }
     

        private void Form1_Load(object sender, EventArgs e)
        {
            btn0.Click += new EventHandler(commonEvent); 
            btn1.Click += new EventHandler(commonEvent);
            btn2.Click += new EventHandler(commonEvent);
            btn3.Click += new EventHandler(commonEvent);
            btn4.Click += new EventHandler(commonEvent);
            btn5.Click += new EventHandler(commonEvent);
            btn6.Click += new EventHandler(commonEvent);
            btn7.Click += new EventHandler(commonEvent);
            btn8.Click += new EventHandler(commonEvent);
            btn9.Click += new EventHandler(commonEvent);
            btnpls.Click += new EventHandler(commonEvent);
            btnmin.Click += new EventHandler(commonEvent);
            btnmul.Click += new EventHandler(commonEvent);
            btndiv.Click += new EventHandler(commonEvent);
            btnmod.Click += new EventHandler(commonEvent);
            btnequ.Click += new EventHandler(commonEvent);

        }

        
        
        

       

        

        
    }
}

here when "TextBox1.Text = ans.ToString" write then give me error !!

Recommended Answers

All 2 Replies

Ciao, john_beginner!
Line 62 should read: TextBox1.Text = ans.ToString();
ToString is a method, all methods have at least (), else it is a field or a property.
Also in the future don't say you have an error, but give a description of the error message you recieve.
That's always more helpfull for us.

hey buddy wats our prob?:?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.