Solved

Use vb6 code to add items to the menu

Posted on 2013-02-01
6
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 47

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
Technology Partners: 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!

 
LVL 47

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 47

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 47
Run code from text file in vb 1 87
which modules are active in VB6 project? 6 52
Problem to line 23 74
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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

756 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