473,414 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Making a lot of stuff Visible and not Visible on a Form

Hi

I have a form with multiple labels and textboxes and listboxes that
need to be made visible and not visible when buttons are clicked. Is
there anyway of grouping them together so that I have less lines of
code instead of 100's of lines stating:

LblA.Visible = True
LblB.Visible = True
LblC.Visible = True
LblD.Visible = True
LblE.Visible = True
LblF.Visible = True ..etc., etc. and then making them not visible
again at a later stage and thus repeating the same lines of code?

By default Visible = False for most of the objects on the form.

Thanks

Mar 3 '06 #1
8 1774
There are a few ways to tackele this.

1) if you labels are named in the way you list them then you could do

dim intX as integer

For intX = 65 to 70
Me.Control("Lbl" & Chr(intx)).Visible = True
Next

The easier way to do this is to name your controls with a number at the end
so say you had

Lbl1,
Lbl2,
Lbl3

You could go

For intX = 1 to 3
Me.Control("Lbl" & Chr(intx)).Visible = True
Next

Another way would be to use the Tag property.

So say you group a bunch of controls by setting the tag property of each of
then to "<<cond1>>"

You could then do this

Dim ctl as Control

For each ctl in Me.Controls
if ctl.Tag = "<<cond1>>" Then
ctl.Visible = false
end if
next

You could then get a bit more subtle and add multiple values in the Tag
property to check against different conditions giving you different
groupings.

--

Terry Kreft
"Hansen" <he******@hotmail.com> wrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
Hi

I have a form with multiple labels and textboxes and listboxes that
need to be made visible and not visible when buttons are clicked. Is
there anyway of grouping them together so that I have less lines of
code instead of 100's of lines stating:

LblA.Visible = True
LblB.Visible = True
LblC.Visible = True
LblD.Visible = True
LblE.Visible = True
LblF.Visible = True ..etc., etc. and then making them not visible
again at a later stage and thus repeating the same lines of code?

By default Visible = False for most of the objects on the form.

Thanks

Mar 3 '06 #2
On Fri, 3 Mar 2006 13:11:38 -0000, "Terry Kreft"
<te*********@mps.co.uk> wrote:

Rather than:
Chr(intx)
use:
CStr(intx)

-Tom.

There are a few ways to tackele this.

1) if you labels are named in the way you list them then you could do

dim intX as integer

For intX = 65 to 70
Me.Control("Lbl" & Chr(intx)).Visible = True
Next

The easier way to do this is to name your controls with a number at the end
so say you had

Lbl1,
Lbl2,
Lbl3

You could go

For intX = 1 to 3
Me.Control("Lbl" & Chr(intx)).Visible = True
Next

Another way would be to use the Tag property.

So say you group a bunch of controls by setting the tag property of each of
then to "<<cond1>>"

You could then do this

Dim ctl as Control

For each ctl in Me.Controls
if ctl.Tag = "<<cond1>>" Then
ctl.Visible = false
end if
next

You could then get a bit more subtle and add multiple values in the Tag
property to check against different conditions giving you different
groupings.


Mar 3 '06 #3
Thanks Guys

Will try these approaches this weekend!

Mar 3 '06 #4
How about something like:
dim ctl
for each ctl in Array(lbl1, lbl2, ..., txtWhatever)
ctl.visible = true
next ctl

Mar 3 '06 #5
"Hansen" <he******@hotmail.com> wrote in
news:11*********************@p10g2000cwp.googlegro ups.com:
I have a form with multiple labels and textboxes and listboxes
that need to be made visible and not visible when buttons are
clicked. Is there anyway of grouping them together so that I have
less lines of code instead of 100's of lines stating:

LblA.Visible = True
LblB.Visible = True
LblC.Visible = True
LblD.Visible = True
LblE.Visible = True
LblF.Visible = True ..etc., etc. and then making them not visible
again at a later stage and thus repeating the same lines of code?

By default Visible = False for most of the objects on the form.


When I need to do this kind of thing, I use a custom collection (or
several of them) make this more efficient. I use the controls' .Tag
property to group them, and walk the Controls collection to set up
the collections.

1. assign appropriate .Tag properties, a unique value for each group
of controls (e.g., "label" for all your labels, "combo" for combo
boxes, "checkbox" for Checkboxes; these are examples since all of
these are things you could find out from checking the ControlType).

2. in the OnLoad event of your form, loop through the Controls
collection and populate your collections, using either the .Tag
property or the .ControlType to determine which collection to assign
them to.

3. once you've done that, then you can loop through each collection
of controls and change properties any way you like.

I've posted more detailed instructions on how to accomplish this in
the past. If you search Google Groups in this newsgroup for my name
and "custom collection" you are likely to be able to find pretty
explicit instructions for how to accomplish the above tasks.

I only use custom collections, though, when I want to switch things
on and off multiple times in a form session. If I just wanted to set
up the form when opening it, I'd just walk the controls collection
and do it once.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Mar 3 '06 #6
bob
How about using different TABS and then dropping whatever controls you like
on them...and setting them to visible..

or even a subform or a few and make them visible based on something else?

"Hansen" <he******@hotmail.com> wrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
Hi

I have a form with multiple labels and textboxes and listboxes that
need to be made visible and not visible when buttons are clicked. Is
there anyway of grouping them together so that I have less lines of
code instead of 100's of lines stating:

LblA.Visible = True
LblB.Visible = True
LblC.Visible = True
LblD.Visible = True
LblE.Visible = True
LblF.Visible = True ..etc., etc. and then making them not visible
again at a later stage and thus repeating the same lines of code?

By default Visible = False for most of the objects on the form.

Thanks

Mar 4 '06 #7
"Hansen" <he******@hotmail.com> wrote in
news:11*********************@p10g2000cwp.googlegro ups.com:
Hi

I have a form with multiple labels and textboxes and listboxes
that need to be made visible and not visible when buttons are
clicked. Is there anyway of grouping them together so that I
have less lines of code instead of 100's of lines stating:

LblA.Visible = True
LblB.Visible = True
LblC.Visible = True
LblD.Visible = True
LblE.Visible = True
LblF.Visible = True ..etc., etc. and then making them not
visible again at a later stage and thus repeating the same
lines of code?

By default Visible = False for most of the objects on the
form.

Thanks

If labels for other controls are actually bound to their
controls, you don't need to worry about the labels, they follow
the control's .visible property.

A snippet from a filter form that has a checkbox labelled
"Filter by Date"

private sub DatesVisible(bShowDates as boolean)
txtOpenFromdate = bShowdates
txtOpenTodate = bshowdates.
txtClosedFromDate = bShowdates
txtClosedToDate = bShowdates
end sub

'the afterupdate event of the control sets the var and calls the
datesvisible sub.

if me.FilterByDates.value then
bshowdates true
else
bshowdates false
endif

--
Bob Quintal

PA is y I've altered my email address.
Mar 4 '06 #8
Yes, I spotted that when re-reading, thanks for the catch Tom.

--

Terry Kreft
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:r7********************************@4ax.com...
On Fri, 3 Mar 2006 13:11:38 -0000, "Terry Kreft"
<te*********@mps.co.uk> wrote:

Rather than:
Chr(intx)
use:
CStr(intx)

-Tom.

There are a few ways to tackele this.

1) if you labels are named in the way you list them then you could do

dim intX as integer

For intX = 65 to 70
Me.Control("Lbl" & Chr(intx)).Visible = True
Next

The easier way to do this is to name your controls with a number at the endso say you had

Lbl1,
Lbl2,
Lbl3

You could go

For intX = 1 to 3
Me.Control("Lbl" & Chr(intx)).Visible = True
Next

Another way would be to use the Tag property.

So say you group a bunch of controls by setting the tag property of each ofthen to "<<cond1>>"

You could then do this

Dim ctl as Control

For each ctl in Me.Controls
if ctl.Tag = "<<cond1>>" Then
ctl.Visible = false
end if
next

You could then get a bit more subtle and add multiple values in the Tag
property to check against different conditions giving you different
groupings.

Mar 6 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sens Fan Happy In OH | last post by:
I'm having majour issues with FrontPage 2K and a webpage that I am having to create from scratch based on someone else's prior work. I hope someone can look at the source code for the page in...
3
by: windandwaves | last post by:
Hi, I am trying to make errors a bit more meaningful for my users. I am trying to fix error 3201 where there is a missing field in a form. If I do not do any error trapping, then I get ...
5
by: john | last post by:
I searched http://www.sellsbrothers.com. and could not find anything about this subject. How do I make C# User Controls Visible to Visual Basic 6.0 Applications? Thanks, John
5
by: Tarscher | last post by:
Hi all, I have a user control and a form. I want the user control to be visible when the form is shown. I haven't found a good webtutorial on this so maybee someone can help me out? regards...
3
by: Dakkar | last post by:
I made a program like i showed below and i used this.Visible = false; line to make it invisible but it doesnt work where did i make mistake ? here is my code
1
by: jodyblau | last post by:
I have a form that is in Continuous form. In each record there is a button next to the a date box. When the button is pushed, the calendar control is set to visible (rather than in a seperate pop...
3
by: Joe | last post by:
I'm connecting to an Oracle database and running a query which returns data. The query can be fairly long - 2-3 minutes. I have a label set up on the form which is invisible to begin with. I...
2
by: Douglas Peterson | last post by:
Was able to reproduce this with a simple example (using .NET 1.1): 1) Create a new WindowsApplication project 2) Add a button to the form and set its Visible property to false 3) Double click on...
69
by: kabradley | last post by:
Alrighty Guys and Gals, I have another question that I hope you all can help me with. I have a report that uses a cross-tab query as its record source. This cross-tab query is getting all of its...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.