making objects invisible

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster

making objects invisible

 
0
  #1
Nov 7th, 2009
Hi,

Let's say I have a form full of objects and want to make all of them (or half of them, whatever) invisible. Is there a short way to do that without a need of setting visible to false individually to each object?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 904
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark
 
1
  #2
Nov 7th, 2009
If you are talking about design time... then,... Drag mouse over all the controls you want to make visible = false. OR, you could put these controls in a frame, picture box, or other container control.

If at runtime..., then,... Same advice. Put the controls in a picture box and set its visiblity = false.

But then there is also this way...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim C As Control
  2. For Each C In Me.Controls
  3. C.Visible = False
  4. Next C



Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 498
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 25
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training
 
0
  #3
Nov 8th, 2009
like this
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. form1.visible = false
  2. image1.visible = false
  3. command1.visible = false
Last edited by abu taher; Nov 8th, 2009 at 1:34 am.
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #4
Nov 8th, 2009
Originally Posted by vb5prgrmr View Post
If you are talking about design time... then,... Drag mouse over all the controls you want to make visible = false. OR, you could put these controls in a frame, picture box, or other container control.

If at runtime..., then,... Same advice. Put the controls in a picture box and set its visiblity = false.

But then there is also this way...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim C As Control
  2. For Each C In Me.Controls
  3. C.Visible = False
  4. Next C



Good Luck
I was talking about runtime, sorry didn't make that clear before.
That code you wrote works like a charm, and it would be the best solution for me, except one problem.. I've got quite a lot objects in my form and some of them doesn't have "visible" property, like Timer for instance. And I also want to leave couple of objects visible, but I guess I can't make that happen this way?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #5
Nov 8th, 2009
I'm sorry, spoke too quickly.. I added "on error resume next" in that cycle, and everything works fine. As concerns those other few objects which I want to leave visible..well, I can put some lines after "For...Next" in the code to set their visibility back to "true". Or maybe there is a way to exclude, let's say, a frame with all it's objects?
Last edited by deftones; Nov 8th, 2009 at 9:54 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 904
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark
 
0
  #6
Nov 8th, 2009
Yes it is possible by testing the C.Container.Name = "Frame1" or ...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim C As Control
  2.  
  3. For Each C In Me.Controls
  4. If C.Container.Name <> "Frame1" And C.Name <> "Frame1" Then
  5. C.Visible = False
  6. End If
  7. Next C

As for a timer control...
If C.Name <> "Timer1" Then

But then again, you could add the timer to the frame and then not need to check to see if c.name = "timer1" within the For Each loop.



Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #7
Nov 8th, 2009
That's just perfect, exactly what I was looking for. Thank you once again!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #8
Nov 8th, 2009
Oh, noticed one thing - this code also hides the whole menu line at the top, how do I prevent that?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: deftones is an unknown quantity at this point 
Solved Threads: 0
deftones deftones is offline Offline
Light Poster
 
0
  #9
Nov 8th, 2009
Figured it out already, problem solved, don't bother
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 507 | Replies: 8
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC