Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 97 VB problem

Status
Not open for further replies.

RonBrown

Technical User
Mar 31, 2000
13
0
0
US
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
 
You need to write

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

or

ToggleAllItems Worksheets("Report").WorkSheet_ListBox, True


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top