We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,453 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Format Exception in Windows Form Help?

Okay, I've got an order form that needs to calculate the total each time a quantity is updated. I have it set up the way I think it should work. I've added one of my methods here for my QuantityBox_TextChanged. I have 3 quantity boxes like this, and I set them all up like this pretty much. When I select a check box, it enables the quantity box - but when I type a number in it, it throws an exception. Any ideas?

private void WhiteFuzzyDiceQuantityBox_TextChanged(object sender, EventArgs e)
    {
        double result = 0.0;
        // exception handling for quantity boxes(no text allowed in them)
        try
        {
            double RedQuantityBox = double.Parse(this.RedFuzzyDiceQuantityBox.Text);
            double BlackQuantityBox = double.Parse(this.BlackFuzzyDiceQuantityBox.Text);
            double WhiteQuantityBox = double.Parse(this.WhiteFuzzyDiceQuantityBox.Text);

            result = (BlackQuantityBox + WhiteQuantityBox + RedQuantityBox)*cost;
        }
        catch(FormatException)
        {
            MessageBox.Show("Not a valid number for quantity box, \nplease enter a number");
        }
        //displays results
        this.DisplayResults(result);
    }
1
Contributor
2
Replies
2 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
kiail
Light Poster
40 posts since Feb 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Oh yeah, it only throws it once, after i put a number in after it throws it, it does what it is supposed to do.

kiail
Light Poster
40 posts since Feb 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
Question Self-Answered as of 1 Year Ago

I figured it out using something else.

kiail
Light Poster
40 posts since Feb 2012
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0613 seconds using 2.66MB