I'm doing a simple order total calculation function and I'm trying to figure out how to display a custom error message when the user input is the incorrect format. I.e. when they enter a non-integer in txtJava.Text, the message will display "Please enter an integer for Java"
private void btnSubmit_Click(object sender, EventArgs e)
{
int Java;
int Latte;
int Mocha;
int Frappe;
string Name = txtName.Text;
double javaPrice = 1.25;
double mochaPrice = 2.95;
double lattePrice = 2.75;
double frappePrice = 3.25;
double dblTaxRate = .09;
double dblSubtotal;
double dblTax;
double dblTotal;
txtMessage.Text = "Thank you " + Name + " for your order!";
Java = Convert.ToInt32(txtJava.Text);
Latte = Convert.ToInt32(txtLatte.Text);
Mocha = Convert.ToInt32(txtMocha.Text);
Frappe = Convert.ToInt32(txtFrappe.Text);
dblSubtotal = Java * javaPrice + Mocha * mochaPrice + Frappe * frappePrice + Latte * lattePrice;
dblTax = dblSubtotal * dblTaxRate;
dblTotal = dblSubtotal + dblTax;
txtSubtotal.Text = dblSubtotal.ToString("C2");
txtTax.Text = dblTax.ToString("C2");
txtTotal.Text = dblTotal.ToString("C2");