|
-
Oct 11th, 2000, 04:16 PM
#1
Thread Starter
Member
I have ten textboxes on my form which are hidden until being populated. My question is: How do I refer to these textboxes when I'm in a loop? For example - I've tried "Text" & z - when z is set to 2 to no avail.
Old Man
[Edited by Old Man on 10-11-2000 at 05:21 PM]
Using VB6 Professional Ediion
-
Oct 11th, 2000, 04:18 PM
#2
Fanatic Member
Change the textboxes into a Control array (set the index property to something other than 0 and their names to the same thing: IE Text1 ...) After you do this, you'd refer to each one by it's name and index like an array: Text1(X) ...
-
Oct 11th, 2000, 04:19 PM
#3
Lively Member
make a control array by naming them all them same and setting the index property starting at zero
you can then refer to them as Text1(x).Visible = True
-
Oct 11th, 2000, 04:21 PM
#4
Or you can do it like this:
Code:
For Each MyControl In Me.Controls
If TypeOf MyControl Is TextBox Then MyControl.Visible = True
Next
-
Oct 11th, 2000, 04:24 PM
#5
You could also...
Code:
Dim Controlx as Control
For Each Controlx In Me.Controls
If TypeOf Controlx Is "TextBox" And Left$(Controlx.Name, 4) = "Text" Then Controlx.Visible = True
Next
WITHOUT setting a control array.
-
Oct 11th, 2000, 04:24 PM
#6
that might cause conflicts if there are more TextBoxes on the form with other uses. If you perfer to use Matthew Gate's solution, I suggest you consider "tagging" the objects you want to work with.
Code:
Dim ctl as Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
If ctl.Tag = "TAGGED" Then
'Do your code here
End if
End if
Next ctl
-
Oct 11th, 2000, 08:33 PM
#7
Thread Starter
Member
Thanks very much for your help! I got it.
Let's do lunch!!
Old Man
Using VB6 Professional Ediion
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|