Using ActionScript

Objectives:

  • Make a dropdown menu in Visual Basic
  • Add multiple forms to a project


Adding Multiple Forms

So far all your Visual Basic projects have only used one form per project. Today we will learn to add forms and then create a dropdown menu.

  1. Start a new project.

  2. Save Form1 as frmMasterTest.

  3. Change the form's caption property to read: Master Project.

  4. Change the form's name property to frmMasterProject.

  5. Save the project as Master Project Test.

  6. Find the add form button in the top left side of your window. It looks like this:



  7. Click on it and add a new form.

  8. Change the name property to frmFirst.

  9. Change the caption to say first.

  10. Save the form as frmFirst.

  11. Repeat the last four steps to create two additional forms, frmSecond and frmThird.

  12. Open up the Project Explorer window by clicking View > Project Explorer. It looks like this:



    Adding a Menu

  13. We are going to add our menu to the form you saved named frmMasterTest. Select that form in your project explorer before you do the next step.

  14. Find the menu editor in the top left corner.



  15. Click on it. You will see this pop up:



  16. Type Projects in the caption box.

  17. Type mnuProjects in the name box.

  18. Click on the next button.

  19. Click on the right arrow button. You will see three dots appear.

  20. Type First in the captions box and mnuFirst in the name box. Click next.

  21. Repeat the last step and input menu items for Second and Third. When finished it will look like this:



  22. Select your master form and click on the word Projects. You should see the menu pop up.

    Coding the Menu

    Finally we come to the last step, writing code to make the menu work.

  23. Click on View > Code.

  24. Click the first drop down arrow and select mnuFirst.



  25. Type in your code to show the form as displayed above.

  26. Repeat the last two steps for your second and third forms.

  27. Now, the last step is to make sure than the master form is the form that starts off when it executes. Click on Project > Properties (the last item). Make sure that under the heading StartUp Object it reads: frmMasterProject. If it doesn't, change it. Note: You can control which form is the start up form through this menu item.

  28. Test out your project.

    << Back to Skyline