Solved

VB6 - Uncheck/clear the listbox (with the style = checkbox)

Posted on 2013-12-27
7
1,917 Views
Last Modified: 2013-12-27
Hello,

How does one go about programmatically uncheck the list box's checkbox selections in vb6?
0
Comment
Question by:Jammerules
  • 4
  • 3
7 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39743042
List1.Selected(0) = False

Where 0 is the ListIndex.
0
 

Author Comment

by:Jammerules
ID: 39743043
   
For x = 0 To lstFileList.ListCount - 1
      If lstFileList.Selected(x) = True Then
         lstFileList.Selected(x) = False
      End If
   Next

Open in new window


I have that code in place. But the problem is I also have another piece of code that triggers off upon ItemCheck event
Private Sub lstFileList_ItemCheck(Item As Integer)
    Dim i, j As Integer
    For i = 0 To lstFileList.ListCount - 1
        If lstFileList.Selected(i) = True Then
            ReDim Preserve arrSourceFilesToBExported(j)
            arrSourceFilesToBExported(j) = lstFileList.List(i)
            j = j + 1
        End If
    Next
End Sub

Open in new window

0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39743047
Create a form-level or global boolean variable. Something like

Public gbIgnore As Boolean

and then

gbIgnore = True
For x = 0 To lstFileList.ListCount - 1
      If lstFileList.Selected(x) = True Then
         lstFileList.Selected(x) = False
      End If
   Next
gbIgnore = False

Open in new window

and
Private Sub lstFileList_ItemCheck(Item As Integer)
    Dim i, j As Integer

    If gbIgnore Then Exit Sub

    For i = 0 To lstFileList.ListCount - 1
        If lstFileList.Selected(i) = True Then
            ReDim Preserve arrSourceFilesToBExported(j)
            arrSourceFilesToBExported(j) = lstFileList.List(i)
            j = j + 1
        End If
    Next
End Sub

Open in new window

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Closing Comment

by:Jammerules
ID: 39743049
Haha! I was just about doing what you said and I got your response! Thanks :)
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39743050
And this code

gbIgnore = True
For x = 0 To lstFileList.ListCount - 1
      If lstFileList.Selected(x) = True Then
         lstFileList.Selected(x) = False
      End If
   Next
gbIgnore = False

Open in new window


could simply be

gbIgnore = True
For x = 0 To lstFileList.ListCount - 1
         lstFileList.Selected(x) = False
   Next
gbIgnore = False

Open in new window

0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39743052
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0
 

Author Comment

by:Jammerules
ID: 39743055
Yup... I glanced through your profile after your first response. I will definitely look into it time permitting! Thanks again for all the invaluable help from peeps like you on this forum.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
A short article about problems I had with the new location API and permissions in Marshmallow
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now