Solved

LISTBOX control

Posted on 1998-12-31
5
152 Views
Last Modified: 2010-05-03
I know is this probably a stupid question, I found a property on the listbox control that allows the items to be checked.  However, I cannot find any way to reference the item if it is checked.  What is the wat to do this?  For example this is what I want to do:

for i =0 to list1.listcount-1
if list1.list(i).value=true then
msgbox(list1.list(i)
end if
next

However, It seems it will not work.  I am setting up a timer event, I want the user to be able to check mutiple hours for the timer to be executed, and I don't want to put 24 checkbox buttons on the form.

Thanks
0
Comment
Question by:windows1
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:vmano
Comment Utility
for the listbox control, there is a property called "Selected". i think that is what you are lookig for.

vmano
0
 
LVL 3

Accepted Solution

by:
jbil earned 100 total points
Comment Utility
Dim i
For i = 0 To List1.ListCount - 1
    If List1.Selected(i) = True Then
     MsgBox (List1.List(i))
    End If
Next
0
 

Author Comment

by:windows1
Comment Utility
Thank you so much!  Also, The listbox is forcing the horizontal scrollbar even thought they all the times fit, it forces a scroll bar and duplicates the last column.   For instances I have a columnt 6 am to noon and a 2nd column from 1 to 6, the one to six is listed 2 times it forces a scroll bar. is there a way to remove this?

thanks
0
 
LVL 3

Expert Comment

by:vmano
Comment Utility
i don't see how my comment is different from jbil's answer. anyway, i will let jbil answer your next question also.

vmano
0
 
LVL 3

Expert Comment

by:jbil
Comment Utility
Scrollbar depends on size of listbox and size of font.
list width has to be wide enough to stop scrollbar.
one way is in design mode fill (list) with num of entries, in your case 12 then stretch the list until it lines up the way you want with no scroll bars. then you can delete the list and add the real list now or at run time.

Thanks for the points
 
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

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

8 Experts available now in Live!

Get 1:1 Help Now