gettingstarted
[Top] [All Lists]

RE: Reading in text from a file into a ListBox with 2 columns

To: "'Getting Started'" <gettingstarted at lists dot realsoftware dot com>
Subject: RE: Reading in text from a file into a ListBox with 2 columns
From: "RBNUBE" <rbnube at mabenterprises dot com>
Date: Sat, 29 Jan 2005 12:47:41 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
Importance: Normal
Keywords: rb-gettingstarted
This line:
Players.ListBox1.Cell(0,1)=Score
...tells the application to always put the data in row 0 (first row).
Use LastIndex instead of 0.



  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=DesktopFolder.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)
    MsgBox s
    Players.ListBox1.InsertRow 1,Name 'this puts the name in the first
row, column 1 as desired
    Players.ListBox1.Cell(ListBox1.LastIndex,1)=Score 'this puts score2
in the first row, column 2; nothing is put in row 2 column 2
  wend
  t.close



-----Original Message-----
From: gettingstarted-bounces at lists dot realsoftware dot com
[mailto:gettingstarted-bounces at lists dot realsoftware dot com] On Behalf Of 
Paul
Young
Sent: Saturday, January 29, 2005 12:16 PM
To: gettingstarted
Subject: Reading in text from a file into a ListBox with 2 columns


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.

Paul

_______________________________________________
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>



_______________________________________________
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>

<Prev in Thread] Current Thread [Next in Thread>