Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-12-27
7
Medium Priority
?
2,179 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 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Closing Comment

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

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 49

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Make the most of your online learning experience.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression
Suggested Courses

636 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