?
Solved

set menu to invisible

Posted on 1998-12-10
7
Medium Priority
?
227 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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