Extract values from a multi-select multi-column list-box
Private Sub cmdRun_Click()
Dim i As Integer, j as Integer
LBoxContractors.BoundColumn = 1
LBoxContractors.TextColumn = 2
If LBoxContractors.ListIndex < -1 Then
j = 0
For i = 0 To LBoxContractors.ListCount - 1
If LBoxContractors.Selected(i) Then
Contractor(j) = LBoxContractors.List(i,0)
VatRegistration(j) = LBoxContractors.List(i,1)
j = j + 1
End If
Next i
End If
End sub
--
Regards,
Tom Ogilvy
Peter wrote in message
...
I have a multi-select list box with the column count property set to 2
The program (before loading the form) sets the range name 'Contractors' to
cover two columns: The contractors' names and their respective VAT
registration numbers.
The form loads Rowsource with Factors!Contractors and shows the names of
the
contractors and their VAT registration numbers. So far so good.
The user is asked to select one (or more) contractors.
I am trying to get the routine below to load the two (Public) string
arrays:
Contractor(xx) and VatRegistration(xx) with the values wherever a
selection(s) is made:
Extract from the 'Run' button code:
Private Sub cmdRun_Click()
Dim i As Integer
LBoxContractors.BoundColumn = 1
LBoxContractors.TextColumn = 2
If LBoxContractors.ListIndex < -1 Then
For i = 0 To LBoxContractors.ListCount - 1
If LBoxContractors.Selected(i) Then
Contractor(i) = LBoxContractors.List(i)
VatRegistration(i) = LBoxContractors.Text
End If
Next i
End If
End sub
The Contractor(i) loads up fine but the VatRegistration(i) has just a NUL
string (""). Can't seem to be able to assign the value in the 2nd column.
Any help or suggestions or ideas or better ways of doing this would be
most
welcolm.
Thanks in advance,
Peter Bircher
|