Question
Adjust the code for the MilestoKilometre GUI converter on C#. If 'Convert' is clicked and there isn't a number in the text box (textBox1) the
Adjust the code for the MilestoKilometre GUI converter on C#. If 'Convert' is clicked and there isn't a number in the text box (textBox1) the output label must say 'Invalid input' instead of 'Distance in kilometres is ___' or 'Distance in miles is ___'
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Conver { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) { label2.Text = ("Distance in kilometres is ___"); double i = Convert.ToDouble(textBox1.Text); label2.Text = "Distance in kilometres is " + Convert.ToString(i * 1.609344);
} if (radioButton2.Checked) {
double i = Convert.ToDouble(textBox1.Text); label2.Text = "Distance in miles is " + Convert.ToString(i / 1.609344); } }
private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked) { label2.Text = ("Distance in kilometres is _"); } }
private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked) { label2.Text = ("Distance in miles is ___"); } }
private void textBox1_TextChanged(object sender, EventArgs e) { } } }
Miles and Kilometres Converter Miles to Kilometres Kilometres to Miles Enter distance:ietbeas) (textBoxl) Convert Distance in kilometres isStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started