Solved

Use vb6 code to add items to the menu

Posted on 2013-02-01
6
453 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 70
How to debug this code 7 61
VBA filters 2 59
Help me. 3 54
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 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…

785 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