stev379 Posted December 29, 2005 Posted December 29, 2005 Why doesn't IsNumber return the correct return? It's coming back as 0 whether I use a number or not. expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", 0) ;0=no, 1=require pre--declare HotKeySet("{ESC}", "Terminate") $font = "Ariel" $Main = GUICreate("",500,200,250,0) ;( "title" [, w, h, l, t]) $Inpt_Add02 = GUICtrlCreateInput("", 30, 30) $btn = GUICtrlCreateButton("IsNumber", 30, 80, 100) $lbl_Add_Chk = GUICtrlCreateLabel("", 200, 100, 200, 60) GuiSetState () ;Run until closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $btn $n = IsNumber(GUICtrlRead($Inpt_Add02)) MsgBox(0, "", "$Inpt_Add02 = " & GUICtrlRead($Inpt_Add02) & @CRLF & "$n = " & $n) If $n = 1 Then GUICtrlSetData($Lbl_Add_Chk, "") $Lbl_Add_Chk = GUICtrlCreateLabel("Please Try again.", 380, 100, 200, 60) GUICtrlSetFont(-1, 14, 400, "", $font) ElseIf $n <> 1 Then GUICtrlSetData($Lbl_Add_Chk, "") $Lbl_Add_Chk = GUICtrlCreateLabel("Numbers only, " & @CRLF & " please.", 380, 85, 200, 60) GUICtrlSetFont(-1, 14, 400, "", $font) EndIf EndSelect Wend Func Terminate() Exit 0 EndFunc
Developers Jos Posted December 29, 2005 Developers Posted December 29, 2005 The Control return a string so you better use : StringIsFloat() SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
stev379 Posted December 29, 2005 Author Posted December 29, 2005 The Control return a string so you better use : StringIsFloat()Cool. StringIsFloat() didn't hold water.StringIsInt() did the job.Thanks!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now