Help with textbox numeric script

Started by Slasher, Tue 20/09/2016 12:37:10

Previous topic - Next topic

Slasher

Hi

I need help with this script to include the number 9 (0-9)... and also not / \ ; etc. Letters sorted.

(not sure why some is greened)

Code: ags

 String text = tbInput.Text;
  
  if (text.Length != fcode){
   // strorint is 0 then enter the text (not numbers), 1 then the numbers
  int i = 0;
  while (i < text.Length)
  {

   if ((strorint==0) &&  (text.Chars[i] >= '0') && (text.Chars[i] >= '9')){
    text = text.Truncate(i);
    tbInput.Text = text;
   }
   else if ((strorint==1) && !((text.Chars[i] >= '0') && (text.Chars[i] >= '9'))){
    text = text.Truncate(i);
    tbInput.Text = text;
   }
   i++;
  }
  fcode=text.Length;


 }





Snarky

I haven't bothered to figure out exactly what you're trying to do, but the issue is in your IF conditions. The first checks that the character is greater than or equal to 0 AND greater than or equal to 9 (you probably want greater than or equal to zero and less than or equal to 9). The second does the same, and here you probably want less than (and not equal) to 0 OR greater than (and not equal) to 9.

Slasher

Cheers Snarky

I'll look into that.......


SMF spam blocked by CleanTalk