Solved

set menu to invisible

Posted on 1998-12-10
7
192 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Accepted Solution

by:
Eklipse earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Expert Comment

by:Eklipse
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB6 convert MSHFlexgrid1 cells 7 52
Problem to delete range 4 54
Help in WHSCRIPT 9 41
Access 2016 VB code 9 86
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now