Click to See Complete Forum and Search --> : FOR EACH


November 4th, 1999, 02:48 PM
I'm trying to loop through all the text boxes on my form and clear the text property. Here is my code that gets an error. What am I doing wrong?

Dim l_text As TextBox
Dim l_form as frmPCReview 'frmPCReview is the name of my form with the controls

For Each l_text In l_form.Controls

l_text.text = ""

Next

Thanks,
Darin
dvanatta@iname.com

Aaron Young
November 4th, 1999, 03:05 PM
Try this:


private Sub Command1_Click()
for Each Control In me
If TypeOf Control is TextBox then Control.Text = ""
next
End Sub





Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com

msrikant
November 4th, 1999, 10:45 PM
Try the following with little changes in your code


Dim l_text as control
Dim l_form as frmPCReview 'frmPCReview is the name of my form with the controls
for Each l_text In l_form.Controls
if typeof I_text is textbox then
l_text.text = ""
end if
next