dimanche 3 mai 2015

Else if loop not executing

I have done this code in c# for my project and I when I try to execute this I'll get -ve numbers. I don't want a number less than zero. That's why I added the else if loop in it. But still its not working. Please help.

 if (myString.Contains(input))
 {
     int pos1 = myString.IndexOf(input);
     int tpos = pos - pos1;
     if (tpos < 20)
     {
         MessageBox.Show("You're Safe", "Important Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         MessageBox.Show(tpos.ToString());
     }
     else if (tpos < 0)
     {
         MessageBox.Show("You are Vulnerable", "Critical Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         MessageBox.Show("You are Vulnerable", "Critical Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }

Aucun commentaire:

Enregistrer un commentaire