Friday, May 1, 2015

else if statement allows false

Hi,

do you set the CustID to a value different from 0 efore entering the if...else block?

If custID is 0 (which will also be the case if the TryParse results in an error) you will get that message.

So maybe change the TryParse to:

            if (Int32.TryParse(txtCustID.Text, out CustID))
            {
                //do code on succes
            }
            else
                MessageBox.Show("No valid Customer ID entered");


Regards,

  Thorsten



No comments:

Post a Comment