gettingstarted
[Top] [All Lists]

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

To: gettingstarted <gettingstarted at lists dot realsoftware dot com>
Subject: Reading in text from a file into a ListBox with 2 columns
From: Paul Young <youngpr at myactv dot net>
Date: Sat, 29 Jan 2005 12:16:08 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
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>

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