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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select All

Status
Not open for further replies.

bebig

Technical User
Oct 21, 2004
111
US
I have a question about "Select All"
If I click "Select All" button, this will select all lists.
But I have an error...
Would you please look over??
This is what I have so far.
----------------------------------
Private Sub SelectAll_Click()

Dim itm As ListItem
Dim bValue

If InStr(Me.SelectAll.Caption, "&Sel") = 1 Then
bValue = True
End If
For Each itm In Me.File1. <---got error...
itm.Selected = bValue
Next

End Sub
---
Thank you in advance.
 
Not sure if this was a typo from when you coppied & paste, but

Code:
 For Each itm In Me.File1.

Should NOT have a "." at the end, so it should be

Code:
 For Each itm In Me.File1

If this was a typo, and you do not have the "." in the real code, then we will have to look further into this

Hope this helps
 
Without ".", I ran it, but I got an error.
it says " object doesn't support this property or method"

 
which control are you using...listbox,listview, checked list box or something else?

the error line should be ...

for each itm in File1.items

but I think that listbox items are declared as objects which means that the best way to get/set the selected state is listbox.getselected/setselected or something similar

try using an index loop ie

for l_iloop=0 to listbox.items.count-1

and use the index of the items instead of the listitem object
 
I tried this, but it still doesn't work..

-----
Private Sub SelectAll_Click()
Dim l_iloop As Integer
Dim itm As ListBox
Dim bValue

If InStr(Me.SelectAll.Caption, "&Sel") = 1 Then
bValue = True
End If
For l_iloop = 0 To File1.ListCount - 1
File1.Selected = bValue
Next

End Sub
---------
error --> .Selected "argument not optional"

---
Please help me....how to approach this problme??

 
In your loop, try something like

Code:
File1.Item(I_iLoop).Selected = bValue
'might be:
File1.Items(I_iLoop).Selected = bValue

This might not be the EXACT code, but I don't have an application open in front of me to test it

Hope this helps more,

 
well...
I tried both ways..
but I still got an error..

---------
Private Sub SelectAll_Click()

Dim iloop As Integer
Dim bValue

If InStr(Me.SelectAll.Caption, "&Sel") = 1 Then
bValue = True
End If
For iloop = 0 To File1.ListCount - 1
File1.Selected(iloop, bValue) --> error says " expected ="
'File1.Item(I_iLoop).Selected = bValue
Next

End Sub
---

Would you please help me??

Thank you in advance
 
Now this one works..

Private Sub SelectAll_Click()

Dim iloop As Integer
Dim bValue

If InStr(Me.SelectAll.Caption, "&Sel") = 1 Then
bValue = True
End If

For iloop = 0 To File1.ListCount - 1

File1.Selected(iloop) = bValue
Next

End Sub

---
Thank you all
 
to set the selected property on an item...

File1.SetSelected(l_iloop,bvalue)


to get the selected property on an item...

File1.GetSelected(l_iloop)


There's no such method/property as 'Selected' for a FileListBox.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top