Sign in to follow this  
Followers 0
nekokk

How to use IsInt function?

3 posts in this topic

#1 ·  Posted (edited)

$quan = inputbox("test","I need an integer",""," M")

;and then I typed a word "5"

If IsInt($quan) then

  MsgBox(0,"test","It's a Integer","")

endif

;The MsgBox never come out......

Did I use it with wrong way?

I would like to know what type the data returned from MsgBox is.

Please help me.

Thank you in advance.

Edited by nekokk

Share this post


Link to post
Share on other sites



Wrong function...

InputBox:

Return Value Success: Returns the string that was entered.

Keyword is string.

Now we look at the StringIsInt() function.

StringIsInt:

Checks if a string is an integer

$quan = inputbox("test","I need a integer",""," M")
If StringIsInt($quan) then
  MsgBox(0,"test","It's a Integer","")
endif
;The MsgBox never come out......

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Oh! it's my bad :evil:

Thank you Burrup.

I also have another problem, that is how to check a string returned from inputbox for plus and minus?

I would like the users to input integer for a number of array, so if them input a string not integer , it will get an error.

$quan = InputBox("Example", "I need an integer", ""," M")
If StringIsInt($quan) then; The users can still input an integer like -100, but this will cause   global $array[$quan][2] ; an error  to declare array.
                          ;How to check minus and plus of an integer?
EndIf

thank you in advance.

I found the function out. :)

Abs function can solve my problem.

$quan = InputBox("Example", "I need an integer", ""," M")
If StringIsInt($quan) then
   $quan = Abs($quan)
   global $array[$quan][2] 
EndIf
Edited by nekokk

Share this post


Link to post
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
Sign in to follow this  
Followers 0