HankD Posted June 13, 2023 Posted June 13, 2023 I want to append a variable with the variable from a for loop. Is this even possible? I've tried this before and have spent a lot of time searching the forums for a solution. This example doesn't work obviously but I hope it gets the idea across. I have gui combo boxes 1 through 4. So I'm trying to take the text $Combo and append it with $foo, resulting in the text $Combo1, $Combo2, $Combo3, $Combo4 So,.. I believe it's make $combined into a string, but I want to use that in place of a Variable that matches the same text. It would then disable the combo box 1 through 4, in this example. For $foo = 1 To 4 $combined = ("$Combo" & $foo) GUICtrlSetState($combined, $GUI_DISABLE) Next
Solution Andreik Posted June 13, 2023 Solution Posted June 13, 2023 There are many ways to do that: Dim $aCombo[5] $hMain = GUICreate('Test') For $Index = 1 To 4 $aCombo[$Index] = GUICtrlCreateCombo('', 10, 30 * $Index + 10, 100, 20) Next GUISetState(@SW_SHOW, $hMain) ; We slowly disable each combo For $Index = 1 To 4 Sleep(1000) GUICtrlSetState($aCombo[$Index], 128) Next Do Sleep(10) Until GUIGetMsg() = -3 or $hMain = GUICreate('Test') $cCombo1 = GUICtrlCreateCombo('', 10, 10, 100, 20) $cCombo2 = GUICtrlCreateCombo('', 10, 40, 100, 20) $cCombo3 = GUICtrlCreateCombo('', 10, 70, 100, 20) $cCombo4 = GUICtrlCreateCombo('', 10, 100, 100, 20) GUISetState(@SW_SHOW, $hMain) ;~ ; We slowly disable each combo For $Index = 1 To 4 Sleep(1000) GUICtrlSetState(Execute('$cCombo' & $Index), 128) Next Do Sleep(10) Until GUIGetMsg() = -3
Nine Posted June 13, 2023 Posted June 13, 2023 Look at Eval/Assign functions in help file. Although I would highly recommend using array instead of your approach. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
HankD Posted June 13, 2023 Author Posted June 13, 2023 oh wow! it's so obvious now that I see it. The array makes a lot of sense & I learned something new with Execute. I did try Assign/Eval but my brain was struggling to apply it to my problem. Thank you Andreik & Nine for the quick responses! Greatly Appreciated!
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