Hallistorm1989 Posted March 10, 2013 Share Posted March 10, 2013 Case $Button3 $Test=GUICtrlRead($Input1) $Amount=GUICtrlRead($Input2) $counter= 0 While $counter<=$Amount MsgBox(0,"Value of $counter is:",$Test) $counter = $counter +1 WEnd For $counter = 1 to $Amount Hello guys. I want that the message box will show up that much times , as it has been declared in the $Input2. Actually its working like i put 5 in the $input2 and it shows up 6 time ( if i put 6 in input box , it shows up 7 times) i already tried this : $counter = $counter +0 but it didnt work. Could anyone help me out with that ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2013 Moderators Share Posted March 10, 2013 Hallistorm1989,Remove the "=" from the condition - then you get the correct number of MsgBoxes: $Amount = 3 $counter = 0 While $counter < $Amount $counter = $counter + 1 MsgBox(0, "Value of $counter is:", $counter) WEndBut it would be best to use a For...Next loop and let AutoIt count for you - like this: For $i = 1 To $Amount MsgBox(0, "Value of $counter is:", $i) NextAll clear? M23 Hallistorm1989 1 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...
Hallistorm1989 Posted March 10, 2013 Author Share Posted March 10, 2013 That easy ? Thank you very much , only question i got is , why its $Amount = 3? it would work if i make $Amount = GUICtrlRead($Input1) aint it ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2013 Moderators Share Posted March 10, 2013 Hallistorm1989,The "3" was just for testing as I did not feel like creating a GUI to hold the input. It will still work with your code - but you might think of ensuring that you have a number in the input before you start looping. M23 Hallistorm1989 1 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...
Hallistorm1989 Posted March 10, 2013 Author Share Posted March 10, 2013 (edited) Hallistorm1989,The "3" was just for testing as I did not feel like creating a GUI to hold the input. It will still work with your code - but you might think of ensuring that you have a number in the input before you start looping. M23Ok , last thing i have to fix is:If i got for if i have -1 in $Input2How Could i block -numbers for this input box ? :/ Edited March 10, 2013 by Hallistorm1989 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2013 Moderators Share Posted March 10, 2013 Hallistorm1989, Do as I suggested - get the content of the input and run some error-checking on it to make sure it is within bounds. Or you could force the input to accept only digits. Something like this should do the trick: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("Only digits accepted!", 10, 10, 200, 20) $cInput_1 = GUICtrlCreateInput("", 10, 30, 200, 20, $ES_NUMBER) ; Force digits only $cInput_2 = GUICtrlCreateInput("", 10, 100, 200, 20) $cButton = GUICtrlCreateButton("Read", 10, 200, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $sContent_1 = GUICtrlRead($cInput_1) $sContent_2 = GUICtrlRead($cInput_2) ; Convert content of Input 2 to an integer $vContent_2 = Int(Number($sContent_2)) ; Check this value to see if it is at least 1 or above If $vContent_2 < 1 Then $vContent_2 = "Error" EndIf MsgBox(0, "Result", "Input 1: " & $sContent_1 & @CRLF & "Input 2: " & $vContent_2) GUICtrlSetData($cInput_1, "") GUICtrlSetData($cInput_2, "") EndSwitch WEnd All clear? M23 Hallistorm1989 1 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...
Hallistorm1989 Posted March 10, 2013 Author Share Posted March 10, 2013 yes , thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2013 Moderators Share Posted March 10, 2013 Hallistorm1989, Glad I could help. I see you got me to code a GUI in the end! M23 Hallistorm1989 1 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