Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need code to display the Messagebox error to display. (c# windows form) Use a try-catch block to prevent the program from crashing if a

I need code to display the Messagebox error to display. (c# windows form)

Use a try-catch block to prevent the program from crashing if a nonnumeric value is entered. The try catch block must prevent the calculation from taking place; it should also prevent any output from being displayed. If nonnumeric data is entered into the text box and Calculate is clicked, then instead we should get an error message via a MessageBox asking us to enter a valid, numeric value.

Code So Far:

namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void textBox2_TextChanged(object sender, EventArgs e) {

}

private void label1_Click(object sender, EventArgs e) {

}

private void label2_Click(object sender, EventArgs e) {

}

private void label3_Click(object sender, EventArgs e) {

}

private void label4_Click(object sender, EventArgs e) {

}

private void btnCalculate_Click(object sender, EventArgs e) { double mealAmount, totalAmount, tipAmount, tax; mealAmount = Convert.ToDouble(foodCharge.Text); tipAmount = mealAmount * 0.15; tax = mealAmount * 0.07; totalAmount = mealAmount + tipAmount + tax; lblTax.Text = tax.ToString("C"); lblTip.Text = tipAmount.ToString("C"); lblTotalAmount.Text = totalAmount.ToString("C"); }

private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

3. Comment on how diversity and equality should be managed.

Answered: 1 week ago

Question

describe the legislation that addresses workplace equality

Answered: 1 week ago