Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginner: Loop through array of textboxes 2

Status
Not open for further replies.

diarratech

Technical User
Jul 7, 2000
41
FR
I have an array of text boxes( 9 text boxes called txtOutput) and I'd like to loop through them. Some data (coming from another form) are going to populate some of the text boxes. I'd like to hide ONLY the text boxes that do not contain any data!
I started with the follwing code but then I got confused!!

For Each ctr_Type In frmSpiderChart.Controls
If TypeOf ctr_Type Is TextBox Then
If ctr_Type.Text = "" Then
ctr_Type.Visible = False
End If
End If
Next ctr_Type
End Sub

This will hide all text boxes. How should I loop trough the text boxes indexes?
Any hint?
Thanks
 
This is a little rought around the edges. Should give you the basic ideer.

For i = 1 to frm.controls.count
If frm.controls(i)Is TextBox Then
with frm.controls(i)
if .Text = "" Then
.Visible = False
End If
End If
Next i

Tyrone Lumley
augerinn@gte.net
 
Dim txt as TextBox

For Each txt in txtOutput
txt.Visible = txt.Text <> &quot;&quot;
Next

Set txt = Nothing

-Mike
Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top