Solved

Performing Math Calculations on TextBox Contents

Posted on 2008-11-01
2
445 Views
Last Modified: 2012-05-05
I have a couple of text boxes on a form that I want to take the contents, perform one mathematical calculation against it and set the contents of a label with the results. I'd like to have the label set upon exit of the text box field. The textbox name is txtOpBudgAmt and the drop down is ddlTime1.

I have attached my code in the OnTextChanged event for the textbox txtOpBudgAmt which isn't working. What am I doing wrong here?

if (ddlTime1.SelectedValue == "Week")
        {
            int intWeeklyAmt Convert Int32(txtOpBudgAmt) * 52;
            lblOpBudgCalcAmt = intWeeklyAmt.ToString();
        }

Open in new window

0
Comment
Question by:Hers2keep
2 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22858461
are you sure this is the code and you are not missing anything
because by just having a look at your code i can see that the code should not compile
modify your code as i have shown below

if (ddlTime1.SelectedValue == "Week")
{
            int intWeeklyAmt = Convert Int32(txtOpBudgAmt.Text) * 52;
            lblOpBudgCalcAmt.Text = intWeeklyAmt.ToString();
}
0
 

Author Comment

by:Hers2keep
ID: 22858630
Okay - i modified your's slightly to the attached which works now. It refreshes the whole page which works, but is slightly annoying. So, I'm going to accept your solution and then try to figure out how to update the label without refreshing the entire page. Maybe an updatepanel...


     double dWeeklyAmt = Convert.ToDouble(txtOpBudgAmt.Text) * 52;
     lblOpBudgCalcAmt.Text = dWeeklyAmt.ToString();

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question