Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting ListBox Values

Status
Not open for further replies.

RobM76

Technical User
Feb 6, 2008
17
CA
Hi,

I'm new to VB6 so, but cannot find how to get a value of a column in a multi column listbox.

i've tried .text and list(x) but these return the whole line from the listbox,

sorry if this is really easy but its starting to do my head in!

Thanks.
 
How have you populated your multi column listbox?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Yes they are populated.

I just want to get a cell value.

Here is my table

ID Name Address
1 Bill Here
2 Ben There
3 Bob Everywhere

and when the user clicks on a row I want the column 2 to be obatined in a textbox.
 
The reason I asked how you're populating the listbox was because the VB6 Listbox doesn't support multi-columns natively.

Are you using VBA?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Getting the items from a listview like this

for x loop
listbox1.AddItem liscview1.additems(x).SubItems(1) & vbtab & listbox1.AddItem liscview1.additems(x).SubItems(2) & vbtab & listbox1.AddItem liscview1.additems(x).SubItems(3)

next

I just found a webpage that said I had to use the mid function! Surely there's a function in VB6 that is the equivelant of VBA's .column(x) function?
 
As I say, the Listbox doesn't support multiple columnns. What you're doing there is using tabs to make it look like there are columns, there's only one column for each entry.

What you can do is something like this
Code:
Debug.Print Split(List1.List(0), vbTab)(1)
That splits the row on vbTab and the bracketed number at the end specifies the 'column' value you want to return (zero based). So my example would print the second 'column' of the first row of data.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thats perfect,

Thanks you very much for your advice and quick responce!!
 
Glad I could help [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top