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

Recommended Answers

All 14 Replies

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.

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();
}

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 = "";
            }
        }
    }
}

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

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

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

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.

@Lusiphur this is not code its just cheating :p

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

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 !!

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

@ 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.

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.