How to Make a Menu in VBS

Written by kevin lee
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Make a Menu in VBS
Impress your friends with VBS menus that run outside the browser. (Asian business people image by huaxiadragon from

VBS, a subset of Visual Basic, allows you to create Web-based and desktop applications quickly. Although VBS has no user interface controls, it can still display HTML buttons, labels and even menus when used with HTA. HTA, short for HTML Applications, serves as a wrapper for VBS. Using these technologies together, you can add useful menus and other controls to your VBS applications.

Skill level:
Moderately Easy


  1. 1

    Open Notepad and paste the following code into a new document:



    <title>HTA Test</title>




    <select size="1" name="Menu1" onChange="ShowSelectedValue">

    &lt;option value="0"&gt;Select a value/option&gt;
    &lt;option value="1"&gt;Value 1&lt;/option&gt;
    &lt;option value="2"&gt;Value 2&lt;/option&gt;
    &lt;option value="3"&gt;Value 3&lt;/option&gt;
    &lt;option value="4"&gt;Value 4&lt;/option&gt;



    This creates a basic HTA document named "VBS Menu." The code between the "<body>" tags adds a drop-down menu containing five values.

  2. 2

    Add the following code after the "</head>" tag:


    Sub ShowSelectedValue

    menu Items = Window.Menu1.SelectedIndex
    selected Text = Window.Menu1.Options(menuItems).Text

    MsgBox selected Text

    End Sub


    This adds a VBS subroutine that runs when you select a menu item. This code stores the index of the item that you choose in "menuItems." For instance, if you choose item two from the menu, "menuItems" will have a value of "2." The "selectedText" variable holds the text value of the selected menu item.

  3. 3

    Click "File" and select "Save As" to open Notepad's "Save As" window.

  4. 4

    Type "My_VBS_Menu_Test.hta" in the "File Name" box and click "Save." This will save the document as an HTA application.

  5. 5

    Open Windows Explorer and navigate to the folder containing the file that you saved. Double-click the file. A window will open and display the VBS menu.

  6. 6

    Click the drop-down arrow and select an item. The code will execute and display the value that you select.

Tips and warnings

  • In this simple example, the VBS subroutine simply displays the selected menu item. You can perform tasks that are more useful by examining the selected menu item's value and executing other functions. For instance, if you create a menu containing file names, you might open a file, depending on the value that a user selects from the VBS menu.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.