Rater Posted February 24, 2008 Share Posted February 24, 2008 (edited) Not sure how best to explain this problem. Seems easiest to have you run this script: If you run this script a couple different times, tweaking it very slightly per my instructions below, you will see the problem right away. (see the "TEST HERE" section in the code) Code as of right now: CASE (A): When "$5.00" is selected in "Budget" combo box, MsgBox reads and returns the text in "Type" column. This works just fine. You can make changes to the "Type" column all day long and MsgBox will always return an accurate result. Great. CASE B: However, if you change the code to say "$6.00 (or any other value besides $5.00)" , MsgBox fails. Here's what I'm trying to do: For each different combination of values selected from the 3 columns in the parent window, when I press "Yes" in the child window, the script will then perform a unique operation. The script seems to almost be working, but I can't get it any closer. I've tried as many things as my noob knowledge will allow, and am now completely out of ideas. Thanks for helping...... CODE#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.11.0 (beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #include <GUIConstants.au3> #include <GUIComboBox.au3> $Parent_Win = GUICreate("schedule", 700, 300) GUISetBkColor(0xCCBBFF) GUISetState(@SW_SHOW) GUICtrlCreateLabel("budget", 188, 35) GUICtrlCreateLabel("quantity", 325, 35) GUICtrlCreateLabel("type", 455, 35) $box1 = GUICtrlCreateCombo("$5.00", 150, 91, 120, 10) GUICtrlSetData($box1, "$6.00 |$7.00 |$8.00") $box2 = GUICtrlCreateCombo("1 pound", 287, 91, 120, 10) GUICtrlSetData($box2, "2 pounds |3 pounds") $box3 = GUICtrlCreateCombo("apples", 425, 91, 120, 10) GUICtrlSetData($box3, "oranges |grapes") $button1 = GUICtrlCreateButton("compute", 250, 220, 130, 40) $Child_Win = GUICreate("START", 330, 150, 400, 300, $WS_CAPTION, -1, $Parent_Win) GUICtrlCreateLabel("compute?", 20, 30, 300, 25, $SS_CENTER) GUICtrlSetColor(4102, 0x0000) GUICtrlSetFont(4102, 10, 550) GUISetBkColor(0xCCBBFF, $Child_Win) $button2 = GUICtrlCreateButton("yes", 60, 80, 80, 30) GUICtrlSetFont(4103, 10, 600) $button3 = GUICtrlCreateButton("no", 190, 80, 80, 30) GUICtrlSetFont(4104, 10, 600) While 1 $msg = GUIGetMsg() $budget = GUICtrlRead(6) $quantity = GUICtrlRead(7) $type = GUICtrlRead(8) If $msg = $button1 Then GUISetState(@SW_SHOW, $Child_Win) EndIf If $msg = $button3 Then GUISetState(@SW_HIDE, $Child_Win) EndIf =================================================================== ; FYI: ; "$button2" is the "Yes" button in child window ; when code says "$5.00" below, user can manually select any value in the "Type" column of parent window, and MsgBox works all day long. ; when code is changed to "$6.00" below, Msgbox stops working ; TEST HERE BEGIN ======================================================= If $msg = $button2 And $budget = "$5.00" Then MsgBox(0, "type is", $type) EndIf ; TEST HERE END ========================================================= Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit EndSelect WEnd Edited February 24, 2008 by Rater Link to comment Share on other sites More sharing options...
MHz Posted February 24, 2008 Share Posted February 24, 2008 If you change it to this then you see the Msgbox every time. ; TEST HERE BEGIN ======================================================= If $msg = $button2 Then MsgBox(0, "type is", $type) EndIf ; TEST HERE END ========================================================= Link to comment Share on other sites More sharing options...
Developers Jos Posted February 24, 2008 Developers Share Posted February 24, 2008 (edited) You have a space after $6.00 which makes the test fail... change this line: GUICtrlSetData($box1, "$6.00|$7.00|$8.00") Its also better to use the Ctrl Handle in this line to avoid problems when changing your gui: $budget = GUICtrlRead(6) should be $budget = GUICtrlRead($box1) etc. Jos Edited February 24, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Rater Posted February 24, 2008 Author Share Posted February 24, 2008 If you change it to this then you see the Msgbox every time. ; TEST HERE BEGIN ======================================================= If $msg = $button2 Then MsgBox(0, "type is", $type) EndIf ; TEST HERE END ========================================================= Yep. Thanks. Link to comment Share on other sites More sharing options...
Rater Posted February 24, 2008 Author Share Posted February 24, 2008 You have a space after $6.00 which makes the test fail... change this line: GUICtrlSetData($box1, "$6.00|$7.00|$8.00") Its also better to use the Ctrl Handle in this line to avoid problems when changing your gui: $budget = GUICtrlRead(6) should be $budget = GUICtrlRead($box1) etc. Jos Yes, deleting the spaces works like a charm. If only I'd known this about 6 hours ago. Also, man that's weird that the control ID doesn't cut it...I got the idea from the Help file. Anyways thanks guys for helping! 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