ListBox.AddRow(<string-from-text-file>)

Hi,

ListBox.AddRow example shows:

Listbox1.AddRow("Sept", "Oct", "Nov", "Dec")

How do I achieve the same function with text readed from a text file:

Pseudo code:

OneLine = ImputTIS.ReadLine Listbox1.AddRow(OneLine)

does not works.

Advices ?

I investigates more after having see ‘Split’ in anoter conversation, to no av.

Even that does not works:

[code] Dim AnArray(-1) As String

AnArray = Split(OneLine,Chr(9))
LB.AddRow(AnArray)

[/code]

But, in the Debugger, AnArray holds correctly the string.

Listbox1.AddRow(“Sept”, “Oct”, “Nov”, “Dec”)
"Does not works too: Sept is in Column 1 and the ListBox have only one Column.
ColumnCount is not set nor at design time nor at run time.

Yeah… I set ColumnCount to 7 (the right value) in code before the AddRow Loop and:

[code]Dim AnArray(-1) As String

AnArray = Split(OneLine,Chr(9))
LB.AddRow(AnArray)[/code]

works fine. So, I will go back to the other, more usefull way to add a row (in three lines).

in the Debugger,
Nice array view.

How that does not works?
No row is added to the LB?
You see only the first item? (in this case, check the LB column count)
Or what?

Hi Antonio,

Something is added in Column 0.

You are right for the Column Count: the Column Count property is automagically inc depending on what the ListBox get in the traditional AddRow, BUT NOT IN THIS SYNTAX.

The traditional syntax is:

LB.AddRow() LocRow = LB.LastRow // Get the Row number I just added LB.Cell(LocRow,-1) = OneLine // OneLine holds

Not tested, I wrote it from memory so…

This syntax avoid me to count the number of \Tab in OneLine and to set the number of columns.

Yes
And lb.cell(-1,-1)= is even better

No !!!

Really ???

You beat me on this one, but it makes sense.

So, I will try later: no more text reading loop ?

You made my day Antonio, even if I already saw the sun (at Strasbourg, France).

Have a great day and many thanks !