Solved

Use vb6 code to add items to the menu

Posted on 2013-02-01
6
452 Views
Last Modified: 2013-02-03
I have a VB6 form.

I added a menu to it, that has a heading "File"  How can I use code to add something to the dropdown menu?

For example, if var1 = "Item1"

Then the VB Menu should say File > Item1

Is there a way to have VB code create the items for File on my menu?
0
Comment
Question by:al4629740
  • 3
  • 2
6 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38845545
This will tell you everything you need to know.
0
 
LVL 14

Expert Comment

by:Faustulus
ID: 38845843
Do we have a bit of a language problem here? If you are having a form anything you put into it is a "Control". There are different types of controls that you can select from the Toolbox. One of them is a ComboBox which would have a drop-down list (not a "menu"). You can add items to that list by using the the Add method of the Control's object. You may find some guidance at this link, http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/c7a82a6a-763e-424b-84e0-496caa9cfb4d/ or simply google "Add item to Combobox". Avoid the word "menu". Microsoft uses the drop-down technology to create menus and you can do that, too. But what you use to create your menu is a "list".
To avoid the pitfalls of wrong nomenclature you might post your workbook with the form to better explain the question.
0
 

Author Comment

by:al4629740
ID: 38846058
Ouch.  Sorry I asked the question.

In any case, I attached a picture of what I'm "trying" to do as a novice programmer.

Note that where it is highlighted on the form, I would like to populate the menu item under File
sample.docx
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 46

Accepted Solution

by:
Martin Liss earned 400 total points
ID: 38846817
Here's a sample project. It's important to note that to do what I think you want you have to use the Menu Editor to add the File menu and it's first subitem. The way I have it set up, neither will show up until the command button is clicked for the first time. Also note that when you create the menu items that you set the properties as shown below.

File menu
'Enabled' checked
'Visible' not checked

First subitem
'Enabled' not checked
'Visible' checked
'Index' set to 0
Project1.zip
0
 
LVL 14

Assisted Solution

by:Faustulus
Faustulus earned 100 total points
ID: 38847812
As I said, MS uses the same technology for their drop-down lists as you can use in yours. In either case you use the Add method for the Items collection of the Control object. Defining the object can be a little tricky and I suggest you read up on it at MSDN. Basically, you have a ControlBar which contains one or more controls. So far, so well. However, the ControlBar is also a Control of the type ControlBar. Therefore the one or several Controls in the ControlBar could also be ControlBars which, therefore, would be populated by other Controls which might or might not be of the type ControlBar.
There is no quick fix, like post a picture and get the code. If you want to figure it out for yourself study the subject. You already created the object. So, I think you know how to address it. Now use the Add method to populate the list. Look for the syntax for the Add method in MS Help.
On the other hand, if you are looking for code post your project. In response to a picture you can only expect to get what you can have easier, better (more comprehensive) and faster by looking the subject up in MS Help and/or the Internet.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38849116
You're welcome and I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2012
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

920 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