Solved

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

Posted on 2013-12-27
7
2,038 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
[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
  • 4
  • 3
7 Comments
 
LVL 47

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 47

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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Closing Comment

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

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 47

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

730 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