Jump to content

Recommended Posts

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
Posted

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......

qq

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

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
  • Recently Browsing   0 members

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