Hi,
I use this code to populate listbox from txt file.
I try to fill only tue second column, the first is has fixed label.
in listBox Open event the first column is filled by following lines
For i = 0 to 360 step 15
LBCompas.AddRow(format(i,“000”)+“°”)
Next
The second column must be filled from file text by code
Dim f As FolderItem
Dim t as TextOutputStream
dim strDateTime, strDate, strTime as string
Dim textInput As TextInputStream
Dim rowFromFile, oneCell As String
Dim i , last As Integer
dim strtxt(5) as string
f = GetOpenFolderItem(“Mag.txt”) //defined as a FileType
If f <> Nil And f.Exists Then
Dim coma As String = ChrB(44)
Dim ligne as String
textInput = TextInputStream.Open(f)
textInput.Encoding = Encodings.UTF8 //strings are MacRoman
Ligne= TextInput.ReadLine
While Not textInput.EOF
rowFromFile = textInput.ReadLine
// Set
If WinMagDev.LBCompas.ColumnCount < CountFields(rowFromFile, coma) Then
WinMagDev.LBCompas.ColumnCount = CountFields(rowFromFile, coma)
End If
WinMagDev.LBCompas.AddRow("")
For i =1 To CountFields(rowFromFile, coma)
oneCell = NthField(rowFromFile, coma, i)
WinMagDev.LBCompas.Cell(WinMagDev.LBCompas.ListCount-1, i-1) = oneCell
Next
Wend
textInput.Close
End If
Return True
When the first column (ListBox Open) is running, the second column (dev) is not populate from the file text.
Populate only when list box LBComps.AddRow() is disactivated.
Set your column count to 25 and run your code for confirmation. You will see the values loaded from the text files in Row 0, Column 1 to Row 24, Column 24 (I think).
Whether Cell or CellValueAt is used, the first parameter should be the desired row (which is i-1) and the second should specify the column (1, i.e. the second column).
Emile,
The first column is fixed does not change label 000° … 360°
only the the dev header column must be filled 20 values.
file text looks like this
,1
,2
,3
.
.
.
,24
Coma is used because the code is wrote to read a row (line)with several columns .
LBCompas.columncount=2
LBCompas.columnwidths="45%,55%"
LBCompas.HasHeading=True
LBCompas.heading(0)="CC"
LBCompas.heading(1)=" dev "
For i = 0 to 360 step 15
LBCompas.AddRow(format(i,"000")+"°")
Loc_Row = LBCompas.LastIndex
LBCompas.Cell(Loc_Row, 1) = "Emile"
Next
When “Emile” line is under comment the first column remain empty.
I discover in data Mag.txt file a blank in the first line .
when blank deleted a file is read from the second line, first line is omitted .
Really Distraught !
Emile i will use an alternative solution, one list box with one column as (labels) .
one list box with one column for data.
Sorry Emile, i have enough abused your time.