deef99 Posted June 21, 2010 Share Posted June 21, 2010 Hello All, Just started this script to have a user enter only 10 digit numbers into the Input Box. Got it so that they can only enter digits, but how do I only allow 10 digits? Can't figure it out! #include "File.au3" #include "String.au3" #include <GUIConstantsEx.au3> $file = "" $foo = "" Example() Func Example() Local $file, $btn, $msg GUICreate("Block Number:", 180, 60, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018) $file = GUICtrlCreateInput("", 12, 5, 100, 20,0x2000) $btn = GUICtrlCreateButton("Post", 130, 12, 40, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $foo = GUICtrlRead($file) ExitLoop EndSelect WEnd Exit EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2010 Moderators Share Posted June 21, 2010 deef99,Try looking at GUICtrlSetLimit in the Help file. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
deef99 Posted June 21, 2010 Author Share Posted June 21, 2010 Duh!!!!! I knew it had to be somewhere...just didn't know where! Thank you for the SUPER FAST REPLY!!!! Link to comment Share on other sites More sharing options...
deef99 Posted June 21, 2010 Author Share Posted June 21, 2010 Hummmm.......... No matter where I put the statement: GUICtrlSetLimit(-1,10,10) it still lets me enter less/more than 10. A quandry... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2010 Moderators Share Posted June 21, 2010 deef99,The limit for an input only applies to the MAX, you have to test for the MIN yourself: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 100, 20) GUICtrlSetLimit(-1, 10, 10) $hButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If StringLen(GUICtrlRead($hInput)) = 10 Then MsgBox(0, "", "You entered 10 numbers") Else ; We have less than 10 MsgBox(0, "", "Please enter at least 10 numbers") EndIf ; No need to test for more because GUICtrlSetLimit does that for us EndSwitch WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
deef99 Posted June 21, 2010 Author Share Posted June 21, 2010 Ok...got that...one more question and I am out of your hair... If they do NOT enter 10, and they can a Msgbox stating to enter 10...how do I reinvoke the Input Box? Sorry...very new to this gui stuff.... D Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2010 Moderators Share Posted June 21, 2010 deef99, As you have not deleted it, it can still be filled. Take a look at this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 100, 20) GUICtrlSetLimit(-1, 10, 10) $hButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If StringLen(GUICtrlRead($hInput)) = 10 Then MsgBox(0, "", "You entered 10 numbers") GUICtrlDelete($hInput) GUICtrlDelete($hButton) GUICtrlCreateLabel("You entered 10 numbers", 10, 10, 200, 20) Else ; We have less than 10 MsgBox(0, "", "Please enter at least 10 numbers") GUICtrlSetData($hInput, "") GUICtrlSetState($hInput, $GUI_FOCUS) EndIf ; No need to test for more because GUICtrlSetLimit does that for us EndSwitch WEnd All clear? Ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
deef99 Posted June 21, 2010 Author Share Posted June 21, 2010 AWESOME!!!!!!!!!!!!!!!!!!! Thank you so very very much! Have a great day! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2010 Moderators Share Posted June 21, 2010 deef99,Have a great day!It is actually very near my bed-time - is it alright if I have a great tomorrow instead? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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