tlman12 Posted June 26, 2008 Posted June 26, 2008 Alright this is probably simple but i cant figure it out what i'm trying to do is create an input box that will only accept 4 numbers and will not continue unless it gets 4 numbers ex. 1234 or 1111 not 12as or aaaa is this possible? thanks
DaRam Posted June 26, 2008 Posted June 26, 2008 While 1 $value = InputBox("Enter Code", "Enter 4 Digits (Numbers Only):", "", " M4") If StringLen($value) = 4 Then If Number(StringLeft($value,4)) Then ExitLoop Else ; Msgbox(... If you want to Warn of an unacceptable input EndIf EndIf Wend Alright this is probably simple but i cant figure it out what i'm trying to do is create an input box that will only accept 4 numbers and will not continue unless it gets 4 numbers ex. 1234 or 1111 not 12as or aaaa is this possible? thanks
zorphnog Posted June 26, 2008 Posted June 26, 2008 (edited) Or make your own: #include <EditConstants.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> $myGUI = GUICreate("Test", 170, 100, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUICtrlCreateLabel("Enter a four digit number:", 10, 10) $inInputBox = GUICtrlCreateInput("", 10, 30, 150, Default, $ES_NUMBER) $btOk = GUICtrlCreateButton("Ok", 10, 65, 70) GUICtrlSetState(-1, $GUI_DISABLE) $bOkEnabled = False $btCancel = GUICtrlCreateButton("Cancel", 90, 65, 70) GUISetState() While 1 $nMsg = GUIGetMsg() $sInput = GUICtrlRead($inInputBox) Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $btCancel Exit Case $nMsg = $btOk MsgBox(4096, "Input received", $sInput) Exit Case StringLen($sInput) > 4 GUICtrlSetData($inInputBox, StringLeft($sInput, 4)) Case StringLen($sInput) = 4 And Not $bOkEnabled GUICtrlSetState($btOk, $GUI_ENABLE) $bOkEnabled = True Case StringLen($sInput) < 4 And $bOkEnabled GUICtrlSetState($btOk, $GUI_DISABLE) $bOkEnabled = False EndSelect WEnd Edited June 26, 2008 by zorphnog
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