-
December 21st, 2003, 05:19 PM
#1
Clear multiple listboxes(Resolved)
Hi everyone ..
I have several listboxes on a form .. named list1 through list12
They are NOT a control array.
I need to clear them on one button click. Currently, I have it as
List1.clear
List2.clear
...
List12.clear
I would like to do this in a loop of some sort.
I tried
For i = 1 to 12
List(i).clear
Next
But that errors out and a For Each Ctrl loop is not clearing the Listboxes.
Any ideas?
Thanks
Michael
Last edited by Hobbit K; December 21st, 2003 at 05:42 PM.
-
December 21st, 2003, 05:25 PM
#2
Code:
dim i as integer
dim strName as string
dim ctl as control
for i = 1 to 12
strName = "List" & i
for each ctl in me.controls
if ctl.name = strname then
ctl.clear
end if
next ctl
next i
Be nice to Harley riders...
-
December 21st, 2003, 05:42 PM
#3
TwoDogs ...
Thanks ... I knew I was close. I was missing the ctrl.name part.
-
December 21st, 2003, 05:46 PM
#4
Glad it worked...I didn't test it
Actually, if those are the only listboxes on the form,
then
Code:
for each ctl in me.controls
if typeof ctl is listbox then
ctl.clear
end if
next ctl
will work just as well
Be nice to Harley riders...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|