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




Reply With Quote