Jump to content

IsNumber failing


stev379
 Share

Recommended Posts

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