Jewtus Posted August 21, 2014 Posted August 21, 2014 (edited) I'm trying to populate a a list guide box with an array of data, but Ian can't seem to get it functional. I read another that said you needed to convert the array to a string prior to using guictrlsetdata and both array to string and guictrlsetdata use | as the delimiter I could do something like this: Guictrlsetdata($Resultlist, _arraytostring ($aresult) ) But it did not work. I also tried to just view it in a massage box as well, but the arraytostring command keeps spitting out blanks. I've even tried to transpose the array (Thinking the vertical might be the issue because it's using @crlf as a delimiter). I've also tried a simpler array (I'm grabbing data from a dB using a ado connection) and it seems to work fine. I'm including my code for additional context. Edited August 21, 2014 by Jewtus
water Posted August 21, 2014 Posted August 21, 2014 Would you please be so kind and enclose your code in AutoIt code tags (that's the blue "A" in the editor).? That enhances readability a lot 232showtime 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Jewtus Posted August 21, 2014 Author Posted August 21, 2014 I'm on a mobile device so I can't but I put into a text file
Moderators Melba23 Posted August 21, 2014 Moderators Posted August 21, 2014 Jewtus,Repost the code and I will format it for you. M23 Jewtus 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Jewtus Posted August 21, 2014 Author Posted August 21, 2014 (edited) expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #cs $Array = "1234|4321" $populateResults = StringSplit($Array,"|",2) $Main = GUICreate("Main Menu", 624, 563, -1078, 138) $Entry = GUICtrlCreateInput("", 8, 26, 121, 21) $SearchButton = GUICtrlCreateButton("Search", 294, 25, 75, 25) $Results = GUICtrlCreateList("", 8, 56, 209, 448) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SearchButton _ArrayDisplay($populateResults) MsgBox(0,"",_ArrayToString($populateResults)) EndSwitch WEnd #ce $sqlConLoans2 = ObjCreate("ADODB.Connection") $sqlConLoans2.Open ($connectionstring) If @error Then MsgBox(0, "ERROR", "Failed to connect to the database") Exit EndIf $Main = GUICreate("Main Menu", 624, 563, -1078, 138) $IDEntry = GUICtrlCreateInput("", 8, 26, 121, 21) $RequestIDEntry = GUICtrlCreateInput("", 157, 26, 133, 21) $SearchButton = GUICtrlCreateButton("Search", 294, 25, 75, 25) $Results = GUICtrlCreateList("", 8, 56, 209, 448) $Label1 = GUICtrlCreateLabel("OR", 135, 30, 20, 17) $CaseSelect = GUICtrlCreateButton("Select Case", 16, 512, 75, 25) $TreeView1 = GUICtrlCreateTreeView(248, 56, 545, 449) $IDLabel = GUICtrlCreateLabel("ID", 10, 9, 26, 17) $RequestIDLabel = GUICtrlCreateLabel("Request ID", 159, 9, 58, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SearchButton If $IDEntry <> '' Then $ID = GUICtrlRead($IDEntry) $sqlRs2 = ObjCreate("ADODB.Recordset") $sqlRs2.open ("Select RequestID from Request where ID = '""$ID""'", $sqlConLoans2) $populateResults = $sqlRs2.GetRows _ArrayDisplay($populateResults) MsgBox(0,"",_ArrayToString($populateResults)) GUICtrlSetData($Results,_ArrayToString($populateResults)) GUICtrlSetData($IDEntry,'') EndIf EndSwitch WEndAll done. M23 P.S. Next time just add these lines manually before and after the code:[code=autoit:0]; code here[/code] Edited August 21, 2014 by Jewtus
water Posted August 21, 2014 Posted August 21, 2014 I see. Even the "Full Version" of the editor seems to be a stripped down version on a mobile device. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Jewtus Posted August 21, 2014 Author Posted August 21, 2014 (edited) Jewtus,Repost the code and I will format it for you. :)M23 Thanks! Also, with the array, it does show the result data when I use the ArrayDisplay command Edited August 21, 2014 by Jewtus
Solution Jewtus Posted August 21, 2014 Author Solution Posted August 21, 2014 AHHH HA! I figured it out. Because I was using GetRows, I need to handle the result as a 2d array. This is how I figured it out $Result = $sqlRs2.GetRows _ArrayDisplay($Result) for $z=0 to (UBound($Result)) -1 MsgBox(0,"",$Result[$z]) Next and I got this error Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Once I changed it to $Result[$z][0] it worked flawlessly
kylomas Posted August 21, 2014 Posted August 21, 2014 jewtus, Just out of curiousity: What does your data source look like? What does $connectionstring contain? Thanks, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Jewtus Posted August 22, 2014 Author Posted August 22, 2014 Not sure exactly what you mean with what does the data source look like... I'm not willing to put the connection string in as its a private database and the connection string has my credentials, but I can say its a SQLOLEDB provider.
kylomas Posted August 22, 2014 Posted August 22, 2014 NP, just curious about your use of SQL with a recordset...been many years since I used the active data object, a refresher is probably in order... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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