View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tokash Tokash is offline
external usenet poster
 
Posts: 2
Default Enabling checkboxes in a listbox control

Ahh, I found the answer from another source.

For those who may have the same problem and are wondering,
it's found in the ".Selected" property.

Dim A As Boolean, Z(9) As String, I As Integer
With Userform1.Listbox1
For I = 0 To 9
.AddItem Z(I)
.Selected(I) = A
End If
Next I
End With

Ok, it was probably easy for the guru's but I'm dumb.
Tok

-----Original Message-----
I know to enable a checkbox for a listbox with a plain
liststyle would be something like:

Userform1.Listbox1.Text = "Listitem1"

How does one do this for an option liststyle? I'm

looking
to be able to multi-select several items in a listbox

with
the listbox liststyle set as an "option" list style with
multiselect property set as "multi".

Here's the code I have:

Dim A As Boolean
With Userform1.Listbox1
For I = 1 To 10
.AddItem Z(I)
If A Then
' Code here to checkbox if A is true.
End If
Next I
End With

Putting in the line "Userform1.Listbox1.Text = Z(I)" only
work for plain liststyles and only if you want one box
checked. It fails when the listbox is setup for
an "option" liststyle with multiselect as "multi".

Is it doable this way or am I just smoking something
really good?
Any advice appreciated!
Thanks,
Tok
.