Click to See Complete Forum and Search --> : collection control


August 18th, 1999, 05:16 PM
Hi all,

I want to clear all text box in my form.
dim ctl as control
for each ctl in control
if typeof ctl Is TextBox then
ctl.text = ""
end if
next

Lothar Haensler
August 19th, 1999, 01:42 AM
pretty close

dim ctl as control
for each ctl in me.controls
if typeof ctl is TextBox then
ctl.text = ""
end if
next ctl

Jan Businger
August 19th, 1999, 02:05 AM
dim ctl as control
for each ctl in form1.controls ' or me.controls
if typeof ctl Is TextBox then
ctl.text = ""
end if
next

_________

Mark my slight correction <form1.controls> or
<me.controls>

Jan

Jan Businger
August 19th, 1999, 02:08 AM
Sorry I didn't see Lothar's reply earlier;
I forgot to add <ctr> to next..so--> next ctr
Do as Lothar suggested

Jan

Chris Eastwood
August 19th, 1999, 03:11 AM
Is there any reason for adding the ctl in :

next Ctl



apart from readability purposes. I only ever mark my 'Next' statements if they are embedded within other 'For' loops and haven't had a problem yet (in-fact, it doesn't matter if you don't mark them when they're embedded).


Just wondering...



Chris Eastwood

CodeGuru - the website for developers
http://www.codeguru.com/vb

Lothar Haensler
August 19th, 1999, 03:16 AM
even worse, if you switch between VB and VBScript as I often have to do, VBScript will complain about the "next i", because it doesn't support that (might have changed in Version 5 for IE 5).

Jan Businger
August 19th, 1999, 06:26 AM
The reaon to add "ctr" after <next>?

More matter of habit.However, it's not necessary at least in VB6 (my experience), I admit.
Thanks Chris.

Jan