Column property in MultiListbox

S

Stuart

I get the message "Could not get the Column property....
Invalid argument" on the following:

Private Sub lbDataCode_Click()
If lbDataCode.ListIndex <> -1 Then
If lbDataCode.Column(1, lbDataCode.ListIndex) <> "" Then <==
tbCtrTrade.Text = lbDataCode.Column(1, lbDataCode.ListIndex)
tbCtrTrade.SetFocus
tbCtrTrade.SelStart = 0
tbCtrTrade.SelLength = Len(tbCtrTrade.Text)
Else
tbCtrTrade.Text = ""
tbCtrTrade.SetFocus
End If
Else
tbCtrTrade.Text = ""
End If
End Sub

Col1 in the listbox is populated correctly, and the user is
about to enter corresponding values into Col2.

Why the message, please?

Regards.
 
T

Tom Ogilvy

Column is zero based, so to work with column 1 use zero, not 1

If lbDataCode.Column(0, lbDataCode.ListIndex) <> "" Then

If you are working with the current selected item you can shorten it to

If lbDataCode.Column(0) <> "" Then

or so sayeth help.
 
S

Stuart

Many thanks,

Regards.

Tom Ogilvy said:
Column is zero based, so to work with column 1 use zero, not 1

If lbDataCode.Column(0, lbDataCode.ListIndex) <> "" Then

If you are working with the current selected item you can shorten it to

If lbDataCode.Column(0) <> "" Then

or so sayeth help.
 

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