Solved

Use vb6 code to add items to the menu

Posted on 2013-02-01
6
455 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

791 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