0

Hey. I'm creating a second degree equation solver in the windows form application.(In the form ax^2+bx+c= 0) And the basic programming is complete but I'm having problems making it bullet proof, in case the user type in the wrong number and type in a =0.

So basically i have an a seperate function to read the numbers, Like this:

```
private void readConstants()
{
{
try
{
aConstant = double.Parse(aConstantTextBox.Text);
while(aConstant == 0)
{
MessageBox.Show("A can't be zero, please retype.");
}
}
catch (FormatException)
{
MessageBox.Show("A has to be a number, please retype.");
aConstantTextBox.Clear();
}
try
{
bConstant = double.Parse(bConstantTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show("B has to be a number, please retype.");
bConstantTextBox.Clear();
}
try
{
cConstant = double.Parse(bConstantTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show("C has to be a number, please retype.");
cConstantTextBox.Clear();
}
// This is just an equation I use to determine wheither the
// solution is complex or not.
R = bConstant * bConstant - 4 * aConstant * cConstant;
}
```

Any suggestions to make this more user friendly? At the moment it isn't quite how i want it.

*Edited 5 Years Ago by Asotop*: n/a