Im validating user entered text, entered into a textbox, to filter out non-numbers,and then compare >= / < to an object pulled from a database. My issue is happening in 2 places though it may be just 1 issue. I have a conversion of a data table item into a string, then into an int. This int is then passed into a series of if /else statements that should validate the users input. After stepping through the program it hits my conversion statement appears to do the conversion, then proceeds to skip my if /else statements.
int classRPM;
int fanRPM;
string actualdata = string.Empty;
char[] entereddata = txfanrpm.Text.ToCharArray();
foreach (char aChar in entereddata.AsEnumerable())
{
if (Char.IsDigit(aChar))
{
actualdata = actualdata + aChar;
using (Fanrpm ds = new Fanrpm(cbdesigntype.SelectedValue.ToString(), cbfansize.SelectedValue.ToString(), cbfanclass.SelectedValue.ToString()))
{
DataTable dt = ds.dataset.Tables[0];
classRPM = Convert.ToInt32(dt.Rows[0].Field<string>("ClassRPM"));
// MessageBox.Show(aChar.ToString());
fanRPM = Convert.ToInt32(actualdata);
if (fanRPM >= classRPM)
{
MessageBox.Show("hi");
}
else if (fanRPM < classRPM)
{
MessageBox.Show("Hide");
}
}
}
else
{
MessageBox.Show(aChar + " is not numeric");
actualdata.Replace(aChar, ' ');
actualdata.Trim();
}
}
txfanrpm.Text = actualdata;
MessageBox.Show(aChar.ToString());code there?