hi sir/maam...i am new member here my name is marlon from batangas city philippines...and i wanna ask something about vb...if i have a lots of textbox in a form...and one button to clear it all textbox...is it possible to use a for loop...like for each textbox or something to make it easier...just using loop???can u show me how...cause i'd try and try...it wont work i dont know why...

what i know is the long method...

textbox1.text=""
textbox2.text="" and so on...

but using a for loop...is it possible..?

thank you sir/maam regards to all...

only if all the textbox's have the same name.... with a different index property. This is called a control array. Click a textbox on the form, right click it and choose copy. Then on the form, right click and choose paste. You'll be told there is already a control with the same name, and then it will ask you if you want a control array. Tell it yes. Then you can loop through them all.

Hi Marlon,

I am not very sure but i think i've done before. Please verify the syntax but the logic is somewhat like this:

for each control in form.controls
if typename(control.name ) = "textbox" then
control =""
end if
next

Hope it help kabayan..

newvbguy

Comments
Good Lead

Hi marlon This is arun From Hyderabad,India

Take this code I think this will help you

dim a as control
For each a in form.controls
if type of control is textbox then
a.text=""
endif
next
:cool:

Comments
Well Done

thank you very much sir...one question pls...in Database why do other programmers used so many connections and recordsets..why?

That is a general question, but it would depend on how many databases you were connecting to, and sometimes programmers like one connection per table or multiple queries. It just depends on what you are doing. Hopefully that helps.

This article has been dead for over six months. Start a new discussion instead.