Jump to content

Problem with IsNumber($var)


Recommended Posts

Hi guys!

I have a problem. If I use this code the program keeps on looping, while $a, $b and $c are all numbers.

Do
     $a=Inputbox("Functie invullen", "Geef een waarde voor a")
     $b=Inputbox("Functie invullen", "Geef een waarde voor b")
     $c=Inputbox("Functie invullen", "Geef een waarde voor c")
Until IsNumber($a) And IsNumber($b) And IsNumber($c)

Hope that you can tell me what I did wrong this time? ;) ty

[-"Scriptkiddie, nice to meet you!"-]

Link to comment
Share on other sites

Usually inputbox by its nature returns text, even if the text is a number.

You might try a test like if $x=int($x) then

or something like that.

...edit " something like that" would be if $x=number($x) then

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Hi guys!

I have a problem. If I use this code the program keeps on looping, while $a, $b and $c are all numbers.

Do
     $a=Inputbox("Functie invullen", "Geef een waarde voor a")
     $b=Inputbox("Functie invullen", "Geef een waarde voor b")
     $c=Inputbox("Functie invullen", "Geef een waarde voor c")
Until IsNumber($a) And IsNumber($b) And IsNumber($c)

Hope that you can tell me what I did wrong this time? :P ty

you could just explicitly typecast it...

Do

$a=Number(Inputbox("Functie invullen", "Geef een waarde voor a"))

$b=Number(Inputbox("Functie invullen", "Geef een waarde voor b"))

$c=Number(Inputbox("Functie invullen", "Geef een waarde voor c"))

Until IsNumber($a) And IsNumber($;) And IsNumber($c)

Link to comment
Share on other sites

Sorry, not hinking striant.

while 1
$num1=InputBox("test number","test","6")
if $num1==number($num1) then 
    msgbox(1,"Numbertest", $num1 & " is number")
Else
    msgbox(1,"Numbertest", $num1 & " is not a number")
EndIf
WEnd

Hope that helps.

Do
     $a=Inputbox("Functie invullen", "Geef een waarde voor a")
     $b=Inputbox("Functie invullen", "Geef een waarde voor b")
     $c=Inputbox("Functie invullen", "Geef een waarde voor c")
Until ($a==number($a) And $b==number($b) And $c==number($c))

..edit forgot a (

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Do
     $a=Inputbox("Functie invullen", "Geef een waarde voor a")
     $b=Inputbox("Functie invullen", "Geef een waarde voor b")
     $c=Inputbox("Functie invullen", "Geef een waarde voor c")
Until (StringIsInt($a) Or StringIsFloat($a)) And (StringIsInt($b) Or StringIsFloat($b)) And (StringIsInt($c) Or StringIsFloat($c))
This works fine, even with "2/3" or something.

Do
     $a=Inputbox("Functie invullen", "Geef een waarde voor a")
     $b=Inputbox("Functie invullen", "Geef een waarde voor b")
     $c=Inputbox("Functie invullen", "Geef een waarde voor c")
     $a = Number($a)
     $b = Number($b)
     $c = Number($c)
Until (StringIsInt($a) Or StringIsFloat($a)) And (StringIsInt($b) Or StringIsFloat($b)) And (StringIsInt($c) Or StringIsFloat($c))

Thanks for your help :mad2:

*EDIT: ;) Not working... If $a = "k", Number($a) = 0 :P

I would think that something like this isn't complicated to script at all :oops:

Edited by Scriptkiddi3

[-"Scriptkiddie, nice to meet you!"-]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...