Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 20th, 2005, 02:11 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Set Listbox Selected property

Hello,

I have a list box where I populate options, say
(1)
(2)
(3)
(4)

and I need to make vba select certain option (ie. say (2) and (4) dynamically)

I have a loop that determines which option should be selected, but I cant seem to use the listbox.Selected(item) property to select specific options with vba. (there is no error, it just doesnt select the options I need it to select) Any Ideas?



code:
Code:
For intCounter = 0 To listCounties.ListCount - 1

            If (Val(listCounties.ItemData(intCounter)) = Val(countiesRecordSet.Fields(0))) Then

                listCounties.Selected(intCounter) = True

          End If

        Next intCounter

Thanks

ÐaÐeVi£
__________________
ÐaÐeVi£
Reply With Quote
  #2 (permalink)  
Old December 21st, 2005, 11:47 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

anyone?

the loop works perfectly, its just the listCounties.Selected(intCounter) = True
part that doesnt do anything.


Thanks

ÐaÐeVi£
Reply With Quote
  #3 (permalink)  
Old December 21st, 2005, 01:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

change the listbox property MultiSelect to 2 (extended)

Marco
Reply With Quote
  #4 (permalink)  
Old December 22nd, 2005, 11:24 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the listbox is already on extended, but still doesnt work. I cant think of what could be wrong.


Thanks

ÐaÐeVi£
Reply With Quote
  #5 (permalink)  
Old December 22nd, 2005, 04:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

put a break in the for loop, and check if the line that selects the list box item is really called (unless you already did it)

Marco
Reply With Quote
  #6 (permalink)  
Old December 23rd, 2005, 04:22 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I tried that and it does get to the line, but it doesnt do anything when it gets there.



ÐaÐeVi£
Reply With Quote
  #7 (permalink)  
Old December 23rd, 2005, 06:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry, I do not any other ideas. The selected property works just fine with me

Marco
Reply With Quote
  #8 (permalink)  
Old October 4th, 2006, 04:04 PM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had this problem and I realized that the list box was set to locked. No error, just nothing got selected. Setting locked property to no fixed this.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListBox not showing correct selected value Shokwave ASP.NET 2.0 Basics 4 June 4th, 2007 08:23 AM
Number of selected items in a listbox sarah lee ASP.NET 2.0 Basics 2 May 17th, 2007 12:20 PM
Get selected values from ListBox to DetailsView gerten ASP.NET 2.0 Professional 0 October 12th, 2006 01:21 PM
selected items in asp:ListBox jtyson Classic ASP Basics 2 July 2nd, 2004 12:01 AM
How to get selected Item from Listbox? Iceman571 ADO.NET 1 March 25th, 2004 06:33 AM



All times are GMT -4. The time now is 07:35 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.