Section 15 Adding menus

One of the basic components of most applications is a set of drop down Menus. Visual Basic offers a simple system to allow menus to be developed. However, code must be written for the Menu to do anything.

To create a menu, ensure that the form is open and active. Obviously, you need to know what menus you need. Use Tools .. Menu Editor. In this case, a menu to clear the drawing and to exit the program are required. To add keyboard equivalents, precede the key letter with a &. For example, use &Clear to make Clear on the menu.. Alt C will work as well as the mouse click.

The code for this should be obvious at this time. However, it is shown:Sub MnuClear_Click () Picrture1.clsEnd Sub
Sum MnuExit_Click () ExitEnd Sub

Add the menu to the graphics program from the previous section.

The Checked property on menus can be useful for indicating what the current selection is within the menu. Assume that the method Picture1.line -(X,Y), QBColor(drawcolor) is active and drawcolor is Red. Then the menu propery Checked would be set to True. MnuRed.Checked=True. (The rest would be set to false).

To setup the program on start, the Form_Load() event should be used.

Group Project 3

Yous task is to write a fully functional programs to achieve one of the following tasks. You must be part of a team of three students. Each student must have a predefined task (such as making a menu system).

  1. Write a Visual Basic that allows the user to draw line, bar and pie charts of their choosing and with their data. They must have the option to choose colours, fill style and labels.
  2. Use a For-Next loop to create a program that will give line patterns similar (and better!) to that shown below. Be creative and add the facility to change colours randomly. You will need to add options to change the pattern type and starting positions. (The starting position could be random.)



Author Mike Leishman

Last Modified 28 June 1998