New topic: Populating listbox
<http://forums.realsoftware.com/viewtopic.php?t=43869> Page 1 of 1 [ 3 posts ] Previous topic | Next topic AuthorMessagevkozme Post subject: Populating listboxPosted: Thu May 03, 2012 10:15 pm Joined: Fri Oct 21, 2005 7:51 pm Posts: 218 Hi, guys, I am trying to make RB read a coma delimited text file (two fields per line) and populate the data into a ListBox that has two colums. For some reason, RB places the entire line from my text file into the first column. Could someone please help me to find a solution? Here is my code. [size=85]Dim t As TextInputStream Dim f As FolderItem Dim dlg As OpenDialog dlg = New OpenDialog f = dlg.ShowModal() // open open dialog for selecting a file to load Dim rowFromFile,oneCell As String Dim i As Integer If f <> Nil Then t =TextInputStream.Open(f) t.Encoding=Encodings.MacRoman //strings are MacRoman Do rowFromFile=t.ReadLine ListBox1.AddRow NthField(rowFromFile,Chr(9),1) For i=1 to CountFields(rowFromFile,Chr(9)) oneCell=NthField(rowFromFile,Chr(9),i) ListBox1.Cell(ListBox1.ListCount-1,i-1)=oneCell ListBox1.CellType(ListBox1.LastIndex,0)=ListBox.TypeCheckBox Next Loop Until t.EOF t.Close End If[/size] Thank you in advance. vkozme Top DaveS Post subject: Re: Populating listboxPosted: Thu May 03, 2012 10:59 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 3647 Location: San Diego, CA Uh... if you are reading a COMMA delimited file... why are you splitting the input line with TABS (chr(9))?????? _________________ Dave Sisemore MacPro, OSX 10.7.3 RB2011r3 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top vkozme Post subject: Re: Populating listboxPosted: Fri May 04, 2012 12:05 am Joined: Fri Oct 21, 2005 7:51 pm Posts: 218 Thanks, Dave, Of course, I need Chr(44) for coma! Now it works. I very appreciate your help. vkozme Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
