954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

in visual basic 6...

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

marlonism
Newbie Poster
4 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

NewVBguy
Junior Poster in Training
71 posts since Mar 2005
Reputation Points: 13
Solved Threads: 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
a.text=""
endif
next
:cool:

arunbnair
Newbie Poster
3 posts since May 2006
Reputation Points: 13
Solved Threads: 0
 

hey slick guys.....

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

marlonism
Newbie Poster
4 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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

marlonism
Newbie Poster
4 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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.

nedwards
Newbie Poster
16 posts since Jul 2006
Reputation Points: 13
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You