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...

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

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

thank you sir/maam regards to all...

Recommended Answers

All 7 Replies

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

Hope it help kabayan..


commented: Good Lead +3

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

commented: Well Done +3

hey slick guys.....

thanks you sir...i appreciate....i got an idea with array...

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.