Textbox to display Listbox 2nd column value

C

Corey

The following is a segment of code i use to populate a Listbox.
I now need to gain the value that when the Listbox3 value is selected(not
multiselect) and place it into Textbox4

Hoiw can i achieve this?
I cannot seem to get the correct syntax for the 2nd column.
If i use Textbox4.value=Listbox3.value, i get the Column 1 value not the
Column 2 Value
********************************************************
ListBox3.AddItem .Cells(myrow, 4).Offset(, i).Value
ListBox3.List(ListBox3.ListCount - 1, 1) = .Cells(myrow, 1).Value
********************************************************

I am sure it is something like:
Textbox4.value=Listbox3(ColumnCount,1).value


Corey....
 
O

OssieMac

Hello Corey,

MsgBox ListBox1.List(ListBox1.ListIndex, 1)

(Note that first column is zero)
 
O

OssieMac

Hi again corey,

What you have done will work but not the standard method. If you put that
code into a listbox click event then you get recursive calls on the event and
would need to disable events.

For interest the following simplified code will also return the 2nd column
value.

MsgBox ListBox1.Column(1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top