Queener Posted August 9, 2013 Share Posted August 9, 2013 (edited) Was wondering if Combobox can pull data from xls or csv? I tested, but didn't work on me. I know how to pull text with filereadline, but this is a bit different from pulling text file. Incase you wondering what data it's pulling... In excel: I have two/more rows A1 = Item1 A2 = Item2 A3 = etc... I want combox to pull those items into combobox. Edited August 9, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Edano Posted August 9, 2013 Share Posted August 9, 2013 (edited) you have to to deformat the lines. uses stringsplit for csv files to get the "," commas out. please provide an example for further help Edited August 9, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) Ok, This works: $Test = Filereadline(@ScriptDir & "\Text.txt", 3) On Text Line3: John|Dong|Pheng Now the hard part is how do I call the Func since the Text file isn't always John|Dong|Pheng? Edited August 9, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Edano Posted August 9, 2013 Share Posted August 9, 2013 you can simply use guictrlsetdata($combobox,"John|Dong|Pheng") [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 yeah but I'm not going use John|Dong|Pheng all the time... I wanted to put it on text file so I can change the name whenever I want to. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Shrapnel Posted August 9, 2013 Share Posted August 9, 2013 (edited) yeah but I'm not going use John|Dong|Pheng all the time... I wanted to put it on text file so I can change the name whenever I want to. asianqueen, here is what i do to fill comboboxes that the values may change from time to time, or have a lot of values that i dont want cluttering up my script: create an INI file [DDLBValues] statesDDLB=|AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NC|ND|NE|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY Then in my script I read the value from the ini file into a string variable and use that to populate the DDLB Local $statesDDLB = IniRead($INI_FileName, "DDLBValues", "statesDDLB", "") Global $cboPropertyState = GUICtrlCreateCombo("", 235, 126, 97, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData($cboPropertyState, $statesDDLB, $defaultPropertyState) Edited August 9, 2013 by Shrapnel Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 I like your example. Can you write an example when calling the function for example if you click IA from the dropdown menu of the combobox; it populate msgbox saying "you selected IA"? Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Shrapnel Posted August 9, 2013 Share Posted August 9, 2013 you would just use GUICtrlSetOnEvent to create a listener for the combo box to change Global $cboPropertyState = GUICtrlCreateCombo("", 235, 126, 97, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetOnEvent($cboPropertyState, "cboPropertyStateChange") and the write a function for it Func cboPropertyStateChange() MsgBox(0, "", "You have selected " & GUICtrlRead($cboPropertyState)) EndFunc ;==>cboPropertyStateChange Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 I'm a bit confuse here. What is $GUI_SS_DEFAULT_COMBO and $CBS_SIMPLE declaring to? I'm getting error saying used before declaration. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Shrapnel Posted August 9, 2013 Share Posted August 9, 2013 I'm a bit confuse here. What is $GUI_SS_DEFAULT_COMBO and $CBS_SIMPLE declaring to? I'm getting error saying used before declaration. Try adding this to the top of your script: #include <GUIConstantsEx.au3> Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 same. Are we grabbing those variable from GUIConstantsEx? Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Shrapnel Posted August 9, 2013 Share Posted August 9, 2013 Post your script so i can see what you have so far Edano 1 Link to comment Share on other sites More sharing options...
Edano Posted August 9, 2013 Share Posted August 9, 2013 Post your script so i can see what you have so far . i said that on the 2nd post [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 Using your example to test before I implemented into mine. #include <GUIConstantsEx.au3> Local $statesDDLB = IniRead("test.ini", "DDLBValues", "statesDDLB", "") Global $cboPropertyState = GUICtrlCreateCombo("", 235, 126, 97, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData($cboPropertyState, $statesDDLB, $defaultPropertyState) Global $cboPropertyState = GUICtrlCreateCombo("", 235, 126, 97, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetOnEvent($cboPropertyState, "cboPropertyStateChange") while 1 sleep(200) WEnd Func cboPropertyStateChange() MsgBox(0, "", "You have selected " & GUICtrlRead($cboPropertyState)) EndFunc ;==>cboPropertyStateChange Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Shrapnel Posted August 9, 2013 Share Posted August 9, 2013 (edited) I am feeling nice today, so here ya go: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Local $statesDDLB = IniRead("test.ini", "DDLBValues", "statesDDLB", "") Global $frmForm = GUICreate("Form", 150, 50, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "frmClose") Global $cboPropertyState = GUICtrlCreateCombo("", 10, 10, 97, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData($cboPropertyState, $statesDDLB, "PA") GUICtrlSetOnEvent($cboPropertyState, "cboPropertyStateChange") GUISetState(@SW_SHOW) while 1 sleep(200) WEnd Func cboPropertyStateChange() MsgBox(0, "", "You have selected " & GUICtrlRead($cboPropertyState)) EndFunc ;==>cboPropertyStateChange Func frmClose() GUIDelete($frmForm) Exit EndFunc ;==>frmClose Edited August 9, 2013 by Shrapnel Queener 1 Link to comment Share on other sites More sharing options...
Queener Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) perfectly what I'm looking for... Is it also possible to assign an id in the ini files too? so like for example ini file [DDLBValues] statesDDLB=|AK|AL|AR [DDLBIDS] statesDDLB2=|1|2|3 with the same method for DDLBIDS - on the label next to combobox; if i select AK, label would display 1. Select AL, label would dsiplay 2, etc...? Or does it need a different ways of doing this? Just need hint this times... Learn alot today! Edited August 9, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Queener Posted August 10, 2013 Author Share Posted August 10, 2013 nvm, I used iniread/iniwrite. Works much better thanks and much appreciated. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Shrapnel Posted August 13, 2013 Share Posted August 13, 2013 glad it is working well for you 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