1,105,417 Community Members

C# code to form a calculator in asp.net

Member Avatar
priyad2
Newbie Poster
3 posts since Mar 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
3
 

please help me with the code behind file..as i am really confused...otherwise give me some tips to start doing the code

Member Avatar
DangerDev
Posting Pro in Training
485 posts since Jan 2008
Reputation Points: 107 [?]
Q&As Helped to Solve: 59 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi
use array of button to make calculator then assign code on button click, on the base of index process the request.

if you are not stick to server side programming you can use javaScript also to make nice calculator.

Member Avatar
sunilcnpd
Newbie Poster
1 post since May 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

please help me with the code behind file..as i am really confused...otherwise give me some tips to start doing the code

This is code for display calculator in asp.net

First use name space using System.Diagnostics;

with in button write down this code

Button1(.................)
{
Process p=new Process();
p.startInfo.FileName="calc";
p.start();
}

Member Avatar
manjunathgc
Newbie Poster
1 post since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        bool plus = false;
        bool minus = false;
        bool multiply = false;
        bool divide = false;
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            
            calci.Text = calci.Text + "1";
            
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "2";
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "3";
        }

        private void button4_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "4";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "5";
        }

        private void button6_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "6";
        }

        private void button7_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "7";

        }

        private void button8_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "8";
        }

        private void button9_Click(object sender, EventArgs e)
        {
            calci.Text = calci.Text + "9";
        }

        private void button10_Click(object sender, EventArgs e)
        {
                calci.Text = calci.Text + "0";
           
        }


        private void button16_Click(object sender, EventArgs e)
        {
            calci.Text = "";
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (calci.Text == "")
            {
                return;
            }
            else
            {
                plus = true;
                calci.Tag = calci.Text;
                calci.Text = "";
            }
           
        }

        private void button15_Click(object sender, EventArgs e)
        {
            if (plus)
            {
                    decimal dec = Convert.ToDecimal(calci.Tag) + Convert.ToDecimal(calci.Text);
                    calci.Text = dec.ToString();
            }
            else if (minus)
            {
                    decimal dec = Convert.ToDecimal(calci.Tag) - Convert.ToDecimal(calci.Text);
                    calci.Text = dec.ToString();
            }
            else if (multiply)
            {
                     decimal dec = Convert.ToDecimal(calci.Tag) * Convert.ToDecimal(calci.Text);
                     calci.Text = dec.ToString();
            }
            else if (divide)
            {
                      decimal dec = Convert.ToDecimal(calci.Tag) / Convert.ToDecimal(calci.Text);
                      calci.Text = dec.ToString();
            }
            return;
        }

                

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button17_Click(object sender, EventArgs e)
        {
            if (calci.Text.Contains("."))
            {
                return;
            }
            else
            {
                calci.Text = calci.Text + ".";
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            if (calci.Text == "")
            {
                return;
            }
            else
            {
                minus = true;
                calci.Tag = calci.Text;
                calci.Text = "";
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            if (calci.Text == "")
            {
                return;
            }
            else
            {
                multiply = true;
                calci.Tag = calci.Text;
                calci.Text = "";
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            if (calci.Text == "")
            {
                return;
            }
            else
            {
                divide = true;
                calci.Tag = calci.Text;
                calci.Text = "";
            }
        }
    }
}
Member Avatar
ddanbe
Posting Expert
5,354 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

Perhaps a look at this thread and the links you find in it could help?

Member Avatar
uzma sattar
Newbie Poster
1 post since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

what is "tag" in this code..??
please reply soon.........

Member Avatar
hassan12345
Light Poster
42 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

This Code is Best in all codes

use these html code in aspx page

>>>>>

<FORM NAME="Calc">
<TABLE BORDER=4>
<TR>
<TD>
<INPUT TYPE="text"   NAME="Input" Size="16">
<br>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" NAME="one"   VALUE="  1  " OnClick="Calc.Input.value += '1'">
<INPUT TYPE="button" NAME="two"   VALUE="  2  " OnCLick="Calc.Input.value += '2'">
<INPUT TYPE="button" NAME="three" VALUE="  3  " OnClick="Calc.Input.value += '3'">
<INPUT TYPE="button" NAME="plus"  VALUE="  +  " OnClick="Calc.Input.value += ' + '">
<br>
<INPUT TYPE="button" NAME="four"  VALUE="  4  " OnClick="Calc.Input.value += '4'">
<INPUT TYPE="button" NAME="five"  VALUE="  5  " OnCLick="Calc.Input.value += '5'">
<INPUT TYPE="button" NAME="six"   VALUE="  6  " OnClick="Calc.Input.value += '6'">
<INPUT TYPE="button" NAME="minus" VALUE="  -  " OnClick="Calc.Input.value += ' - '">
<br>
<INPUT TYPE="button" NAME="seven" VALUE="  7  " OnClick="Calc.Input.value += '7'">
<INPUT TYPE="button" NAME="eight" VALUE="  8  " OnCLick="Calc.Input.value += '8'">
<INPUT TYPE="button" NAME="nine"  VALUE="  9  " OnClick="Calc.Input.value += '9'">
<INPUT TYPE="button" NAME="times" VALUE="  x  " OnClick="Calc.Input.value += ' * '">
<br>
<INPUT TYPE="button" NAME="clear" VALUE="  c  " OnClick="Calc.Input.value = ''">
<INPUT TYPE="button" NAME="zero"  VALUE="  0  " OnClick="Calc.Input.value += '0'">
<INPUT TYPE="button" NAME="DoIt"  VALUE="  =  " OnClick="Calc.Input.value = eval(Calc.Input.value)">
<INPUT TYPE="button" NAME="div"   VALUE="  /  " OnClick="Calc.Input.value += ' / '">
<br>
</TD>
</TR>
</TABLE>
</FORM>

<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>

Thanks
Islam is the Best

Member Avatar
Lusiphur
Practically a Posting Shark
852 posts since Jun 2010
Reputation Points: 185 [?]
Q&As Helped to Solve: 134 [?]
Skill Endorsements: 4 [?]
Team Colleague
Featured
 
1
 

Well congratulations everybody on just handing out code to someone. My particular favorite was this one:

Button1(.................)
{
Process p=new Process();
p.startInfo.FileName="calc";
p.start();
}

That being said... when someone comes to the forum and says "please help me with the code behind file..as i am really confused...otherwise give me some tips to start doing the code" do you think that they benefit more from having completed code snippets dropped in their lap or from being told how to go about coding the application they're working on?

DangerDev and ddanbe good on you two for pointing the user in the right direction :twisted: At least some folks are still following the 'developmental learning' model around here as opposed to the 'here's a free hand out, go turn it in to your teacher' model.

Now as to the original question, similar to ddanbe I'm going to provide a reference to another thread. Perhaps the information in that thread will help you sort out your calculator code issue.

Member Avatar
hassan12345
Light Poster
42 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

@Lusiphur this is not code its just cheating :p

Member Avatar
aizalee
Newbie Poster
1 post since Mar 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi hassan12345
I have created the calculator already with the codes in aspx page,
my problem is how to get this calculator get going. . pls help me =)
I need the codes for the aspx.cs page
thank you

Member Avatar
hassan12345
Light Poster
42 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

dear aizalee it just a html and javascript code you can use it any code like asp,php,jsp etc
and i already test it it give you gui with best calculation result !!

Member Avatar
hassan12345
Light Poster
42 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

aizalee i check your code and remove your error
check above link and download code and enjoy it
http://www.4shared.com/file/Od1IHKAa/Asp_Calculater_with_masterPage.html

Member Avatar
hscoder
Newbie Poster
6 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-2
 

Down load full source code for making EMI calculator in c#

http://www.authorcode.com/how-to-make-emi-calculator-using-c/

Member Avatar
Momerath
Senior Poster
3,830 posts since Aug 2010
Reputation Points: 1,327 [?]
Q&As Helped to Solve: 664 [?]
Skill Endorsements: 19 [?]
Featured
 
0
 

Really? You think the original poster is still looking for code after 3 years?

Member Avatar
Zvjezdan23
Junior Poster
153 posts since Dec 2010
Reputation Points: -13 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

@ Lusiphur: I am a beginner as well and I am also learning c# by myself now. I have a book on ASP.Net 3.5 and Silverlight 3 as well. i really think that these guys that have typed out the code and posted it on here help out a lot. Beginners like myself like that people like these guys and gals are willing to post up their code on here. We "noobs" (if you will) like to learn from the professionals because we do need help. I needed help on a Yahtzee game in c++ a while back and a couple of guys and gals really helped me out. They made some code for me and I intertwined it into my code. They helped me with resizing the screen and a little bit of the scoring function. When you have completed code like this, I myself can understand what's going on and try to fill in the gaps myself; if not at least make some adjustments from their code and maybe re-write their same code over so I can have it in my head. We like to use references when we are in school and I love it when others see that we really do want to learn. So Thank You all that have ever posted up code as well as complete code in these forums. God Bless All of You and Your Families As Well.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article