Real Software Forums
http://forums.realsoftware.com/

Populating listbox
http://forums.realsoftware.com/viewtopic.php?f=1&t=43869
Page 1 of 1

Author:  vkozme [ Thu May 03, 2012 10:15 pm ]
Post subject:  Populating listbox

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

Author:  DaveS [ Thu May 03, 2012 10:59 pm ]
Post subject:  Re: Populating listbox

Uh... if you are reading a COMMA delimited file... why are you splitting the input line with TABS (chr(9))??????

Author:  vkozme [ Fri May 04, 2012 12:05 am ]
Post subject:  Re: Populating listbox

Thanks, Dave,

Of course, I need Chr(44) for coma! Now it works.

I very appreciate your help.

vkozme

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/