Results 1 to 13 of 13

Thread: clunk....help.

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    3

    clunk....help.

    Hi everyone,
    I do believe i require some assistance in a program I'm creating for an assignment. i have it working, all except for the Try-catch statement. it works, it highlights the error, yet it keeps on crashing the program when i click the ok button. it also highlights the
    dblCost = Convert.ToDouble(txtAdults.Text) * 40 + Convert.ToDouble(txtChildren.Text) * 20 of the second portion of code as the error whenever a non-numerical value is entered. Its quite frustrating and I do wish to keep the frontal portion of my skull intact, so could someone please help.

    Code:
            Dim dblCost As Double
    
            Try
                dblCost = Convert.ToDouble(txtAdults.Text) * 40 + Convert.ToDouble(txtChildren.Text) * 20
            Catch exception As System.Exception
                MessageBox.Show("Error, please input a number(s) greater than 0", "ERROR!", MessageBoxButtons.OK)
                Clear_Text()
            End Try
    
    
    dblCost = Convert.ToDouble(txtAdults.Text) * 40 + Convert.ToDouble(txtChildren.Text) * 20 
    txtAmountDue.Text = "The total amount due is R" + dblCost.ToString
    Last edited by Twisted_Bobbay; Apr 19th, 2009 at 06:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width