Sign in to follow this  
Followers 0
stev379

IsNumber failing

3 posts in this topic

Why doesn't IsNumber return the correct return? It's coming back as 0 whether I use a number or not. :P

#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

Share this post


Link to post
Share on other sites



The Control return a string so you better use : StringIsFloat()

Cool.

StringIsFloat() didn't hold water.

StringIsInt() did the job.

Thanks!! :P

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