I'm having a problem with checking textboxes and making sure there's only integers in them.
So far I'm able to confirm that there's text in the textboxes, but checking if they're integers isn't working. Here's my code that so far works.
if (textBox1.Text.Length == 0)
{
errorProvider1.SetError(textBox1, "need Cost of Disks");
return;
}
if (textBox2.Text.Length == 0)
{
errorProvider2.SetError(textBox2, "need Total disks in package");
return;
}
if (textBox3.Text.Length == 0)
{
errorProvider3.SetError(textBox3, "need the Gigabyte per disk");
return;
}
try
{
Double[] myValues = new Double[3];
myValues[0] = Double.Parse(textBox1.Text);
myValues[1] = Double.Parse(textBox2.Text);
myValues[2] = Double.Parse(textBox3.Text);
Double ppd = myValues[0] / myValues[1] / myValues[2];
ppd = Math.Round(ppd, 3, MidpointRounding.AwayFromZero);
label4.Text = ppd.ToString();
}
catch (FormatException)
{
//errorProvider1.SetError(label4, "testing1");
//errorProvider2.SetError(label4, "testing2");
//errorProvider3.SetError(label4, "testing3");
return;
}