Solved

Determing if a check box is checked in a list box

Posted on 2002-04-12
2
184 Views
Last Modified: 2010-05-02
Hi,
I  have a list box using the checkbox style.
Is there a way to determine if a certain item in the list is checked? If not, what good is the checkbox ?

I am using the ItemCheck event when I click on an item to check or uncheck it, but I don't see how to determine if the item is checked or not.

Thanks

Jeff
0
Comment
Question by:jscharpf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 6937684
use the Selected collection:

Option Explicit

Private Sub Command1_Click()
Dim intI As Integer

    For intI = 0 To List1.ListCount - 1
        If List1.Selected(intI) Then MsgBox List1.List(intI) & " is selected!"
    Next
End Sub

Private Sub Form_Load()
    With List1
        .AddItem "item 1"
        .AddItem "item 2"
        .AddItem "item 3"
        .AddItem "item 4"
        .AddItem "item 5"
    End With
End Sub
0
 

Author Comment

by:jscharpf
ID: 6937710
That's exactly what I needed!!
Thanks emoreau!!

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question