×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Excel 97 VB problem

Excel 97 VB problem

Excel 97 VB problem

(OP)
I'm trying to generalize a listbox clear/select all items routine.  First wrote the clear all and select all items routines, but the only difference is that the Select(iItem) is set True for Select and False for clear.  So I wrote a Toggle All Items routine with parameters for the Listbox and the status and tried to call this from the Clear All and Select All routines, but VB says there is a syntax error in the call statement on line 12 of the below code and seems to want an equal somewhere in the statement.  I know the code in the commented out section, lines 14 through 19 works, so this should work after the call to the Toggle All Items routine corrected.  Any ideas?

1   Private Sub ToggleAllItems(lbListBox As ListBox, bStatus As Boolean)
2     Dim iItem As Integer
3  
4     For iItem = 0 To lbListBox.ListCount - 1
5       lbListBox.Selected(iItem) = bStatus
6     Next
7     lbListBox.MultiSelect = fmMultiSelectExtended
8   End Sub
9
10 Private Sub SelectAll_Button_Click()
11
12   ToggleAllItems(Worksheets("Report").WorkSheet_ListBox, True)
13  
14   '  Dim iItem As Integer
15   '
16   '  For iItem = 0 To Worksheets("Report").WorkSheet_ListBox.ListCount - 1
17   '    Worksheets("Report").WorkSheet_ListBox.Selected(iItem) = True
18   '  Next
19   '  Worksheets("Report").WorkSheet_ListBox.MultiSelect = fmMultiSelectExtended
20 End Sub
21
22 Private Sub ClearAll_Button_Click()
23   .
24   .
25   .
26 End Sub

Thanks,
Ron Brown

RE: Excel 97 VB problem

You need to write

Call ToggleAllItems(Worksheets("Report").WorkSheet_ListBox, True)

or

ToggleAllItems Worksheets("Report").WorkSheet_ListBox, True


 

RE: Excel 97 VB problem

(OP)
Thanks!

Ron Brown

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close