[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

Use vb6 code to add items to the menu

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
al4629740
Asked:
al4629740
  • 3
  • 2
2 Solutions
 
Martin LissRetired ProgrammerCommented:
This will tell you everything you need to know.
0
 
FaustulusCommented:
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
 
al4629740Author Commented:
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
Independent Software Vendors: 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!

 
Martin LissRetired ProgrammerCommented:
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
 
FaustulusCommented:
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
 
Martin LissRetired ProgrammerCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now