Click here to Skip to main content
15,908,274 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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
    {
        string s1, s2,oper;
        public Form1()
        {
            InitializeComponent();
        }

        private void btn0_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn0.Text;
        }

        private void btn1_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn1.Text;
        }

        private void btn2_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn2.Text;
        }

        private void btn3_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn3.Text;
        }

        private void btn4_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn4.Text;
        }

        private void btn5_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn5.Text;
        }

        private void btn6_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn6.Text;
        }

        private void BTn7_Click(object sender, EventArgs e)
        {
            textBox1.Text += BTn7.Text;
        }

        private void btn8_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn8.Text;
        }

        private void btn9_Click(object sender, EventArgs e)
        {
            textBox1.Text += btn9.Text;
        }

        private void btnpoint_Click(object sender, EventArgs e)
        {
            string s = textBox1.Text;
            int j = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '.')
                {
                    j = 0;
                    break;


                }
                else
                {
                    j = 1;
                }

             }
            if (j == 1)
            {
                textBox1.Text += btnpoint.Text;
            }
        }

        private void btnPlus_Click(object sender, EventArgs e)
        {
            string s1 = textBox1.Text;
            textBox1.Text = "";
            oper = "+";

        }

        private void btneql_Click(object sender, EventArgs e)
        {
            int e1;
            double equal;
            if (oper == "+")
            {
                string s = textBox1.Text;
                int j = 0;
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == '.')
                    {
                        j = 0;
                        break;


                    }
                    else
                    {
                        j = 1;
                    }

                }
                if (j == 1)
                {
                    string s2 = textBox1.Text;
                    e1 = int.Parse(s1) + int.Parse(s2);
                    textbox1.text=e1.ToString();
                }
                else
                {
                    string s2 = textBox1.Text;
                    equal = double.Parse(s1) + double.Parse(s2);
                     textbox1.text=equal.ToString();
                }
            }
        }
    }
}
In this calculator program when i try to add two number than error is coming "Value cannot be null. Parameter name: String"
please tell me how can i remove it??
Posted
Updated 9-May-13 21:19pm
v3
Comments
Alexander Dymshyts 10-May-13 3:20am    
may be your parameter btn.Text is null. You need to do debuging to see where value is null
♥…ЯҠ…♥ 10-May-13 3:23am    
Try to use debugger in VS, it would help in tracing the bug. Then you can clear the bug at one shot.
sakshi111 10-May-13 3:31am    
how to use debbuger in visual studio

1 solution

problem has been resolved
actually i define string s1 and s2 two times
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900