Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

set menu to invisible

Posted on 1998-12-10
7
Medium Priority
?
232 Views
Last Modified: 2010-05-03
Hi

I tried the following code

Dim vControl As Control
For Each vControl in Me
   If TypeOf vControl Is Menu Then
      vControl.Visible = False
   End If
Next vControl

without successfull. That was because the last sub-menu's visible property can not be set to false (I think).

Can you tell me how to do the job?
0
Comment
Question by:learn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Accepted Solution

by:
Eklipse earned 150 total points
ID: 1449406
I don't know the reason too.
But I suggest this:
Put On error resume next in the beggining of the procedure like this

Sub MenuHide
On error resume next
Dim vControl As Control
    For Each vControl in Me
       If TypeOf vControl Is Menu Then
          vControl.Visible = False
       End If
    Next vControl
End sub

The problem persist but you solve the problem.

Good Luck
Fer

0
 
LVL 3

Expert Comment

by:Sendoh
ID: 1449407
Hi !
This is because of the parent item had been set to false for "Visible". If you tried to set the sub menuitem (not only last), error msg popup.
Anyway, you solve this problem by many ways,
   1) Ignore the error message by "On error go next".
   2) Create the menu using control array.
   etc.

Hope it'll help you !! ^_^
0
 

Author Comment

by:learn
ID: 1449408
To Sendoh

>>>>>>>>
This is because of the parent item had been set to false for "Visible". If you tried to set the sub menuitem (not only last), error msg popup.
>>>>>>>>

The above is not true! I have tried set invisible one menu be one menu and found that we can set invisible to the sub-menu even its parent menu had been set invisible, but not the last sub-menu.

To Eklipse:

Using "On error resume next" in the code shows VB is not a very good languege....I wish we have a Menu collection and can code like "Menus.Visible = false".

Learn
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Eklipse
ID: 1449409
I'm apologize but I thought that you need a solution.
The solution works.I tried to help you.
You don't like the solution.Well, I understand.
Please reject the 'not very good languege' solution and somebody will help you better.
Every problem accept more than one way to solve it and there are better ones and bad ones.
 PD:Examine the 2) item of Sendoh's comment.Maybe is an approach to a better solution

Good luck and Happy christmas
Fer



0
 

Author Comment

by:learn
ID: 1449410
To  Eklipse:

Thank you very much.
As you may guess that I am learning VB instead of using it to make softwares.
I have also tried your answer and found that is correct. However, if you don't mind, I would like to wait for a few days to see if there is any better solusion.

Merry Xmas.

To Sendoh:
 
Can you explain more detail on how to "Create the menu using control array"?

Cheers.

Learn
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 1449411
Hi !
The control array method is quite simple.
First of all, when you create the menu, there is this "Index" field on the menu editor. By specifying the same name for all parent menu(the one shown on screen) with different index(normally start at 0 and so on).
Let said you menu as follow:

      File
      ----Test
      ----Test2
      Edit
      ----Edit 1
      ----Edit 2
      Help
      ----About
The main menu item here is "File","Edit" and "Help".
so you just specifiy the control name as the same name let said "MainMenu" and the different index as well (in this case File-0,Edit-1,Help-2).

The when you need to hide all the visile menu(instead of gone through all the menu + submenu) you can just hide the parent menu.

The code as follow:

    Dim i As Integer
   
    For i = 0 To 2
        MainMenu(i).Visible = False
    Next i

Hope it'll suit you !! ^_^
Merry Christmas !!
0
 

Author Comment

by:learn
ID: 1449412
To Eklipse:

Thank you for your answer and comment. You should get the point.

Happy Xmas.

Learn

To Sendoh:

I haven't got time to test your suggestion but it looks very nice. Thank you.
I will post another question, "Question for Sendoh.", with zero pont. I may ask you something related to this original question or may include nothing. If you answer that, you can get 50 points.

Happy Xmas.

Learn
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question