|
-
July 16th, 2008, 03:46 PM
#1
Symbolic naming
does anyone know how to do this in a for loop in VB6
'txtHI6_Ln5(TabStrip1.SelectedItem.Index - 1).Visible = True
'txtHI6_Ln6(TabStrip1.SelectedItem.Index - 1).Visible = True
'txtHI6_Ln7(TabStrip1.SelectedItem.Index - 1).Visible = True
'txtHI6_Ln8(TabStrip1.SelectedItem.Index - 1).Visible = True
'txtHI6_Ln9(TabStrip1.SelectedItem.Index - 1).Visible = True
'txtHI6_Ln10(TabStrip1.SelectedItem.Index - 1).Visible = True
'txtHI6_Ln11(TabStrip1.SelectedItem.Index - 1).Visible = True
For i = 5 to 11
txtHI6_Ln"i"(TabStrip1.SelectedItem.Index - 1).Visible = True
...
next i?
Thanks , Marc
Last edited by aa173130; July 16th, 2008 at 03:56 PM.
-
July 17th, 2008, 01:38 AM
#2
Re: Symbolic naming
You could try something like :
Code:
Dim I As Integer, Ctl As Control
For i = 5 to 11
Set Ctl = Me.Controls("txtHI6_Ln" & Format(i)) ' The Trick Is here :)
Ctl(TabStrip1.SelectedItem.Index - 1).Visible = True
Next i
Give that a shot, it should work. here, I loop from 5 to 11, then, I set the current found control, equal to a variable named Ctl - lastly, I set the Visible property
I hope it helps!
-
July 17th, 2008, 04:53 AM
#3
Re: Symbolic naming
Another approach might be to put the textboxes in a frame. Then setting the frame's Visible property can show or hide all the boxes at once.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
July 23rd, 2008, 12:13 AM
#4
Re: Symbolic naming
I like the frame idea...very clever...will add that to my tools.
I usually use an array/collection for looping though objects and performing the same method.
You could code the array as
dim txtArray(11) as TextBox
then assign each text box to an index in the array.
use a stepping for loop or a do while loop with a counter to loop through the indexes of the array and perform the method or change the property you want.
The collection could be used if all the textboxes need it done.
Dim colTextBoxes as Collection
Use the collections add method to add the textboxes to the collection.
You then can use a for each next loop to call the method or set the property for the contents of the whole collection.
Hope this helps.
Btw HanneStheGreat, your code looks like .Net Code...however the concept would work by accessing the forms control collection.
Last edited by VehementSoftware; July 23rd, 2008 at 12:15 AM.
-
July 23rd, 2008, 08:07 AM
#5
Re: Symbolic naming
 Originally Posted by VehementSoftware
Btw HanneStheGreat, your code looks like .Net Code...however the concept would work by accessing the forms control collection.
Hi.
Nope, that is pure VB 6 code.
-
July 23rd, 2008, 10:08 AM
#6
Re: Symbolic naming
Sorry Hannes, I thought Me was used in .Net, I have never used in 6.0. Just remembered it's My in .Net. Forgive me, still kind of a noob.
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
|