Getting a row from a listbox

I’m looking for a less complex mechanism for building a string based on the column contents of a listbox row. In digging through the OLR, I discovered that Listbox.List should return the entire row as a string including all column contents for that row. Unfortunately, the OLR page doesn’t really go into any details on how the resulting string should be assembled.

When I tried a quick test, all I got was the contents of column 0 when there are 18 columns with data.

Bug? Bad docs?

Well, it has always been this way.
But looping over the columns to get the contents, assemble them into an array and return the resulting string them via join should be very fast, or am I overlooking something?

This is not what the LR says. From the docs:

So List returns the value of column 0.

Loop over the columns of the row to assemble a string representation. This is hardly a “complex mechanism”. An example:

Dim values() As String For columnIndex As Integer = 0 To lbx.ColumnCount - 1 values.Append(lbx.Cell(rowIndex, columnIndex)) Next Dim s As String = Join(values, ";")

Ah, there is also
myCompleteRowString=Listbox1.cell(rowNumber,-1)

-1 serves as a magic value for “entire row”.

@Eli Ott - That gets my embarrassing D’oh of the day :). I totally misread the entry.

@Maximilian Tyrtania - Thanks. I knew there was a way, but couldn’t remember.

To get a tab Delimited string containing all the columns:

Dim S as String = Listbox1.Cell(row,-1)

To get the contents of the entire listbox that way (each line is row)

Dim S as String = Listbox1.Cell(-1,-1)

To get a tab Delimited string containing all the columns:

Dim S as String = Listbox1.Cell(row,-1)

So if you Want and Array:
Dim S() as String = Split(Listbox1.Cell(row,-1), TAB)

Were TAB is a constant

To get the contents of the entire listbox as string (each line is row) that can be directly pasted into Excel:

Dim S as String = Listbox1.Cell(-1,-1)