You must Sign In to post a response.
  • Category: ASP.NET

    I am doing web calculator project How to write add and equaltwo coding in c#.

    Hi Friends

    I am doing web calculator project How to write add and equal two coding in c#. Plz guide me. +-*/ button 1 to 4 5 is equal two.

    coding


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace WebApplication1
    {
    public partial class WebForm1 : System.Web.UI.Page
    {

    protected void Page_Load(object sender, EventArgs e)
    {


    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }

    protected void Button13_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 1;
    }

    protected void Button14_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 2;

    }

    protected void Button15_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 3;

    }

    protected void Button9_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 4;

    }

    protected void Button10_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 5;

    }

    protected void Button12_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 6;

    }

    protected void Button6_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 7;

    }

    protected void Button7_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 8;

    }

    protected void Button8_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 9;

    }

    protected void Button17_Click(object sender, EventArgs e)
    {

    TextBox1.Text = "";

    }

    protected void Button16_Click(object sender, EventArgs e)
    {
    TextBox1.Text = TextBox1.Text + 0;

    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    double total1 = 0;
    total1 = total1 + double.Parse(TextBox1.Text);

    }

    protected void Button5_Click(object sender, EventArgs e)
    {

    }
    }
    }


    wds
    vrameshsrinivasan
    vramesh2019@gmail.com
  • #769422
    You can refer following link.
    http://www.c-sharpcorner.com/UploadFile/ad779a/basic-calculator-in-C-Sharp/

  • #769430
    Hi find the below code for calculator

    <html>
    <head>
    <title>My Very Simple HTML Calculator</title>
    </head>
    <body>
    <style>

    .name{
    position: absolute;
    color: white;
    float: right;
    padding-left: 183px;
    font-size: 10px;
    margin-top: 12px;
    font-weight: bold;
    }

    </style>
    <form name="calculator">
    <!-This is a line which you can change the color on the bordercolor and bgcolor->
    <div class="name">THOTA</div>
    <table border="4" cellpadding="1" bordercolor="#00000" bgcolor="#000000" cellspacing="2" width="222">
    <tr>
    <td>
    <input type="text" size="25" length="25" value="" name="ans" style="background:beige;color:black;">
    </td>
    </tr>
    </table>
    <!-This is a line which you can change the color in the bordercolor and bgcolor->
    <table border="4" cellpadding="2" bordercolor="#00000" cellspacing="2" width="222" bgcolor="000000">
    <tr>
    <td align="center">
    <input type="button" value=" 7 " name="seven" onclick="document.calculator.ans.value+='7'">
    </td>
    <td align="center">
    <input type="button" value=" 8 " name="eight" onclick="document.calculator.ans.value+='8'">
    </td>
    <td align="center">
    <input type="button" value=" 9 " name="nine" onclick="document.calculator.ans.value+='9'">
    </td>
    <td align="center">
    <input type="button" value=" / " name="divide" onclick="document.calculator.ans.value+='/'">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" value=" 4 " name="four" onclick="document.calculator.ans.value+='4'">
    </td>
    <td align="center">
    <input type="button" value=" 5 " name="five" onclick="document.calculator.ans.value+='5'">
    </td>
    <td align="center">
    <input type="button" value=" 6 " name="six" onclick="document.calculator.ans.value+='6'">
    </td>
    <td align="center">
    <input type="button" value=" * " name="multiply" onclick="document.calculator.ans.value+='*'">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" value=" 1 " name="one" onclick="document.calculator.ans.value+='1'">
    </td>
    <td align="center">
    <input type="button" value=" 2 " name="two" onclick="document.calculator.ans.value+='2'">
    </td>
    <td align="center">
    <input type="button" value=" 3 " name="three" onclick="document.calculator.ans.value+='3'">
    </td>
    <td align="center">
    <input type="button" value=" - " name="subtract" onclick="document.calculator.ans.value+='-'">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" value=" C " name="clear" onclick="document.calculator.ans.value=''">
    </td>
    <td align="center">
    <input type="button" value=" 0 " name="zero" onclick="document.calculator.ans.value+='0'">
    </td>

    <td align="center">
    <input type="button" value=" = " name="equal"
    onclick="document.calculator.ans.value=eval(document.calculator.ans.value)">
    </td>
    <td align="center">
    <input type="button" value=" + " name="add" onclick="document.calculator.ans.value+='+'">

    </td>
    </tr>
    </table>

    </form>

    </body>
    </html>


    Find the attached screenshot for the same.

    Sridhar Thota.
    Editor: DNS Forum.

    Delete Attachment


  • Sign In to post your comments