dim f as FolderItem
dim t as TextInputStream
dim s as String
f=PreferencesFolder.child("filename.plist")
t=f.OpenAsTextFile
while not t.eof
s = t.ReadLine
ListBox1.AddRow NthField(s, ",",1)
ListBox1.Cell(ListBox1.LastIndex, 1) = NthField(s, ",", 2)
Wend
t.close
P.
*********************
on 1/29/05 12:16 PM, Paul Young at youngpr at myactv dot net wrote:
> I'm a new RB 5.5.4 programmer using Mac OS 10.3.7.
>
> I'm trying to read a simple text file into a ListBox with two columns.
> The text file has two lines; name1,score1 and name2,score2.
>
> The following Method code fills the first column cells properly but I
> cannot get the second column to fill properly:
>
> dim f as FolderItem
> dim t as TextInputStream
> dim s as String
> dim Name as String
> dim Score as String
> dim Comma as Integer
> f=PreferencesFolder.child("filename.plist")
> t=f.OpenAsTextFile
> while not t.eof
> s=t.ReadLine
> Comma=Instr(s,",")
> Name=Left(s,Comma-1)
> Score=Mid(s,Comma+1)
> Players.ListBox1.InsertRow 1,Name 'this puts the name in the first
> row, column 1 as desired
> Players.ListBox1.Cell(0,1)=Score 'this puts score2 in the first
> row, column 2; nothing is put in row 2 column 2
> wend
> t.close
>
> When I delete the second row in the text file, both row 1 cells are
> filled correctly. Score2 is writing over Score1.
>
> What am I doing wrong?
>
> Thanks for the assistance.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|