Solved

Performing Math Calculations on TextBox Contents

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now