Control names

BadScript

Registered User.
Local time
Yesterday, 16:22
Joined
Oct 30, 2007
Messages
73
I tried to search this forum but so far no results. If this question was already asked I apologise. In my VB I use the following script.
I was wondering if there's a way to make this script shorter

lbl13.Visible = False
lbl14.Visible = False
lbl15.Visible = False
lbl16.Visible = False
lbl17.Visible = False
lbl18.Visible = False
lbl19.Visible = False
lbl20.Visible = False
lbl21.Visible = False
lbl22.Visible = False
lbl23.Visible = False
 
Yes you can loop through the controls collection in the form and then modify a particular control according to some key value associated with that control.

Typically you can prefix the names of the controls you want to modify like this: lblX13 then your code is designed to detect the "X" and modify controls marked Thus accordingly.

You could alternatively add a value within the tag property detect this value and take action accordingly.

The code you would use would be something like this:

Dim Ctl as Control

For Each Ctl in me.controls
if Ctl.tag = "X" then Ctl.Visible = False
Next Ctl
 
Thanks alot !
I'm a beginner and this will make it alot easier for me :)
 

Users who are viewing this thread

Back
Top Bottom