Knight Posted December 6, 2005 Share Posted December 6, 2005 I am trying to get the text of all the items in a listbox and store it into an array. I have looked at all the standard functions and UDF's in the help menu, as well as searched the forums. I am either blind or overlooked something. Is there any efficient way of doing this without having to select each item and record it into the array? Thanks -JKnight Link to comment Share on other sites More sharing options...
GaryFrost Posted December 6, 2005 Share Posted December 6, 2005 (edited) expandcollapse popup#include <GUIConstants.au3> #include <GuiList.au3> opt('MustDeclareVars', 1) Dim $msg, $ret Dim $listbox, $label, $button, $x GUICreate("ListBox Get Text Demo", 400, 250, -1, -1) $listbox = GUICtrlCreateList("", 125, 40, 180, 120) GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|") $button = GUICtrlCreateButton("Get", 165, 180, 90, 25) $label = GUICtrlCreateLabel("Item #", 150, 210, 120) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $listbox $ret = _GUICtrlListGetText ($listbox, _GUICtrlListSelectedIndex ($listbox)) If ($ret == $LB_ERR) Then MsgBox(16, "Error", "Unknown error from _GUICtrlListGetText") Else GUICtrlSetData($label, "Item : " & $ret) EndIf Case $msg = $button Dim $a_list For $x = 0 To _GUICtrlListCount ($listbox) - 1 If Not IsArray($a_list) Then Dim $a_list[1] Else ReDim $a_list[UBound($a_list) + 1] EndIf $a_list[UBound($a_list) - 1] = _GUICtrlListGetText ($listbox, $x) Next For $x = 0 To UBound($a_list) - 1 MsgBox(0, $x, $a_list[$x]) Next EndSelect WEnd Edited December 6, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Knight Posted December 6, 2005 Author Share Posted December 6, 2005 Thank you very much gafrost. Ill try it out when I have time! 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