We help IT Professionals succeed at work.

ListBox selected property in vb

ube100
ube100 asked
on
389 Views
Last Modified: 2013-12-25
Hi,
I got my listbox control with the style property set to checkbox. Now I wanted to display those ticked one to the user when I receiving the earlier saved settings from the table in the database. So I done the following in my form module:

With lstBrand
        Do Until oRec.EOF        
            For iIndex = 0 To lstBrand.ListCount - 1
                If oRec.Fields("brdBrandName") = .List(iIndex) Then
                  .Selected = True
                End If
            Next iIndex
        iBrandIndex = iBrandIndex + 1
        oRec.MoveNext
        Loop
    End With

But when I run this I'm the getting the follwing error at the ".Selected = true" statement:

Compiler error:

Argument not optional

Can someone tell me what do I doing wrong here? Do I need to include the ItemData property?
If so, how?
Comment
Watch Question

Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Excellent!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.