Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add code to the buttonShowNext that will do this following when the user clicks:

ID: 668583 • Letter: A

Question

Add code to the buttonShowNext that will do this following when the user clicks:

Create a Try and Catch block statement to store the code and trap the error if one occurs.

Declare a string variable called Currency

Declare a double variable called Amount

Then set the value of the Amount variable to the text value in the textBoxAmount

Then set the value of the Currency variable to the value in the textBoxCurrency

You will need to Parse the string stored in the text box (textBoxAmount) to a double in order to successfully assign its value to the double Amount variable.

Display a string in a Message Box similar to the following:

  You have selected to convert "Amount" "Currency"

Finally, if the user enters bad data (non-numeric in the txtBoxAmount text box), a Message box pops up and says:

  An error has occurred while parsing the amount entered!

C#

Explanation / Answer

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1{
public partial class Form1 : Form{
public Form1(){
InitializeComponent();
}
  
private void Form1_Load(object sender, EventArgs e){
   textBox1.Width = 100;
   textBox1.Height = 20;
   textBox1.Multiline = true;
textBox1.BackColor = Color.Blue;
textBox1.ForeColor = Color.White;
textBox1.BorderStyle = BorderStyle.Fixed3D;
  
textBox2.Width = 100;
   textBox2.Height = 20;
   textBox2.Multiline = true;
textBox2.BackColor = Color.Blue;
textBox2.ForeColor = Color.White;
textBox2.BorderStyle = BorderStyle.Fixed3D;
  
  
button1.Text = "Click Here";
}

private void button1_Click(object sender, EventArgs e){
string Currency;
double Amount;
if (textBox1.Text == "" || textBox1.Text == ""){
   MessageBox.Show("An error has occurred while parsing the amount entered!");
}
else{
   Currency = textBox1.Text;
   try{
       Amount = Convert.ToDouble(TextBox2.Text);
   }
   catch(Exception){
       MessageBox.Show("An error has occurred while parsing the amount entered!");
   }
}
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote