Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual Basic (Classic) FAQ


Adding items to a menu at run-time by JESTAR
Posted: 6 May 03

Open your Menu Editor. I'm using a Bookmark system as an example, you can add URL's to your menu then open Internet Explorer straight to that page. Adapt it as you wish.

Set up this in your Menu Editor, the Indexes are what you need to add:

Bookmark (name= mnuBookmarkTop)
...Add a Bookmark (name = mnuBookmark, Index = 0
...Launch Internet Explorer (name = mnuBookmark, Index = 1)
...- (name = mnuBookmark, Index = 2)

The names are the same, so it's a control array. Now to add the items. I used an InputBox here. The user enters the URL, and it appears on the menu under the last item. They can then click it to open IE to that page. Here's the code:

Private Sub mnuBookmark_Click(Index As Integer)
    Dim Bookmark As String
    Dim I As Integer
    Select Case Index
    Case 0:
        'Display the InputBox for the user to enter the URL
        Bookmark = InputBox("Enter the URL to Bookmark", "Bookmark a website")
        'Get the next available index in the menu
        Load mnuBookmark(mnuBookmark.ubound + 1)
        'Write the Caption of the new item as the URL
        mnuBookmark(mnuBookmark.ubound).Caption = Bookmark
    Case 1:
        Shell ("C:\Program Files\Internet Explorer\IExplore www.google.com";), vbMaximizedFocus
    Case Else
        Shell ("C:\Program Files\Internet Explorer\IExplore " & mnuBookmark(Index).Caption), vbMaximizedFocus
        End Select
End Sub

That's it.

Back to Visual Basic (Classic) FAQ Index
Back to Visual Basic (Classic) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close