Solved

Performing Math Calculations on TextBox Contents

Posted on 2008-11-01
2
448 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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