al1nm3ar Posted May 8, 2012 Share Posted May 8, 2012 hi @all i declared about 60 checkboxes ($Checkbox1, $Checkbox2, etc) and a button to uncheck all boxes at once; no i have the problem that i need to get the for loop working so that it should state i=1 GUICtrlSetState($Checkbox1, $GUI_UNCHECKED) i=2 GUICtrlSetState($Checkbox2, $GUI_UNCHECKED) etc. my problem shows up when i wanted to adress my variables $Checkbox with the for loop with $Checkbox & $i : for $i = 1 To 16 GUICtrlSetState( $Checkbox & $i , $GUI_UNCHECKED) Next Any good advice for me? Link to comment Share on other sites More sharing options...
MrMitchell Posted May 8, 2012 Share Posted May 8, 2012 (edited) I'm not sure but I think you'll need Eval() Edit: Like this: Eval("Checkbox" & $i) - Quotes around Checkbox and don't use the dollar symbol before Checkbox, only use $ before the i Edited May 8, 2012 by MrMitchell Link to comment Share on other sites More sharing options...
ZacUSNYR Posted May 8, 2012 Share Posted May 8, 2012 Good advice? Put your checkboxes all in the same array. Loop through the array. Solution to your current problem - check the helpfile for "Assign" and "Eval". Link to comment Share on other sites More sharing options...
al1nm3ar Posted May 8, 2012 Author Share Posted May 8, 2012 thx for really quick answering; solution: for $j = 1 To 16 GUICtrlSetState( Eval("Checkbox" & $j) , $GUI_UNCHECKED) Next thx @ MrMitchell Link to comment Share on other sites More sharing options...
MrMitchell Posted May 8, 2012 Share Posted May 8, 2012 Here's a way to use Assign() and Eval() to create them and manipulate them... For $i = 1 to 10 Assign("Checkbox" & $i, GUICtrlCreateCheckbox("Checkbox #:" & $i, $i * 10, $i * 10)) Next For $i = 1 To 10 GUICtrlSetState(Eval("Checkbox" & $i), $GUI_UNCHECKED) Next If you use Assign() to create it you can't assign to an array element according to the Help File so you'd have to create individual variables like you have already done. Then if you wanted to use an array to store the ControlIDs, maybe something like this... Dim $array[11] = ["10"] For $i = 1 To 10 $array[$i] = GUICtrlCreateCheckbox("Checkbox #:" & $i, $i * 20, $i * 20) Next For $i = 1 To 10 GUICtrlSetState($array[$i], $GUI_CHECKED) Next Link to comment Share on other sites More sharing options...
Mechaflash Posted May 8, 2012 Share Posted May 8, 2012 (edited) For $i = 1 To 10 $array[$i] = GUICtrlCreateCheckbox("Checkbox #:" & $i, $i * 20, $i * 20) Next If its just a checkbox reset button, just tell it to uncheck all checkboxes without looking at the current status of the checkbox. Stealing above... ;Use this to create the checkboxes Global $aCheckboxes[60] For $i = 0 To 59 Step 1 $aCheckboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i + 1, ...) Next ;Use this to uncheck all of them For $checkbox in $aCheckboxes GUICtrlSetState($checkbox, $GUI_UNCHECKED) Next Edited May 8, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” 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