Menu at run-time

Posted on 1999-01-12
Last Modified: 2010-05-03

I use VB6.
How can i add new topics to menu at runtime?
How free am i modifing menu at runtime?

Question by:hpet

Accepted Solution

jjbyers earned 50 total points
ID: 1455719
Your very free at run-time to add menu items.

Look at the SDINote.vbp sample app that comes with VB5.

Hope this helps.

Expert Comment

ID: 1455720
Create a control array e.g. mnuFileItem(0), mnuFileItem(1) and so on at design time. Then set the visible property to False for the blank menu controls, and set the visible property to True once you've added text in a control.


Expert Comment

ID: 1455721
Here is an example of some menu items being added at run time.  This is based off of a table with some names that are inserted into the menu.  Hope this helps.

rstNames is the recordset that contains the names.
mnuFileOpenName(Name_Idx) is the menu item array.  During design time, set the index property to zero.

Do Until rstNames.EOF

      If Name_Idx > 0 Then
          Load Me.mnuFileOpenName(Name_Idx)
'Here we are loading the next instance of the menu item, we only load if it is greater than zero because the menu item with index zero was created at design time.
      End If

        Me.mnuFileOpenName(Name_Idx).Caption = rstNames!Name 'set the caption for the new menu item
      Me.mnuFileOpenName(Name_Idx).visible = true 'showing the new menu item
        Name_Idx = Name_Idx + 1 'increment the load index
        rstNames.MoveNext 'move to the next record

LVL 14

Expert Comment

ID: 1455722

Author Comment

ID: 1455723
Sorry for delay...


Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
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 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…

760 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

26 Experts available now in Live!

Get 1:1 Help Now