Maikey81 0 Posted March 15, 2012 Is it possible to check the value of a ComboBox against the values of other ComboBoxes? The only thing I can think of is by making an IF statement for each of the ComboBoxes. But that means I'm getting a lot of code, because I have 10 combo boxes. Goal is to check if the selected value is not the same as the value in one of the other ComboBoxes. Share this post Link to post Share on other sites
ZacUSNYR 4 Posted March 15, 2012 (edited) You need to think with an array. You DO have to check all combos. But if you keep all the controls in an array you can run the array through a loop. An example I tossed together. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $ahCombo[10][2] $t = 25 Opt("GUIOnEventMode", 1) $hGUI = GUICreate("ComboTest", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") For $i = 0 To UBound($ahCombo) - 1 $ahCombo[$i][0] = GUICtrlCreateCombo("", 10, $t, 150, 20) GUICtrlSetData(-1, "Choice1|Choice2|Choice3|Choice4|Choice5|Choice6|Choice7|Choice8|Choice9|Choice10|Choice11|Choice12") GUICtrlSetOnEvent(-1, "_ComboSelection") $t += 25 Next GUISetState(@SW_SHOW, $hGUI) While 1 Sleep(10) WEnd Func _ComboSelection() Local $sComboTxt Local $iExists = 0 For $i = 0 To UBound($ahCombo) - 1 If @GUI_CTRLID = $ahCombo[$i][0] Then $sComboTxt = GUICtrlRead(@GUI_CTRLID) For $n = 0 To UBound($ahCombo) - 1 If $ahCombo[$n][1] = $sComboTxt Then $iExists = 1 GUICtrlSetBkColor($ahCombo[$n][0], 0xFF0000) GUICtrlSetState($ahCombo[$n][0], $GUI_FOCUS) ExitLoop Else GUICtrlSetBkColor($ahCombo[$n][0], 0xFFFFFF) GUICtrlSetState($ahCombo[$n][0], $GUI_FOCUS) ContinueLoop EndIf Next If $iExists Then GUICtrlSetBkColor($ahCombo[$i][0], 0xFF0000) GUICtrlSetState($ahCombo[$i][0], $GUI_FOCUS) Else GUICtrlSetBkColor($ahCombo[$i][0], 0xFFFFFF) GUICtrlSetState($ahCombo[$i][0], $GUI_FOCUS) $ahCombo[$i][1] = $sComboTxt EndIf ExitLoop EndIf Next EndFunc Func _Exit() Exit EndFunc Edited March 15, 2012 by ZacUSNYR Share this post Link to post Share on other sites
ZacUSNYR 4 Posted March 15, 2012 heh that's a little broken but it gets the gist of it down for ya. Share this post Link to post Share on other sites