Menus, Combo Boxes and QB Color
Menu - A drop-down list of items displayed below a menu name on the screen from which you selected one item.
In both Windows and VB, a menu consists of a menu bar with menu names, each of which drops down to display a list of menu commands. You can use menu commands in place of or in addition to the command buttons to activate a procedure.
Menu commands are actually controls and have events and properties. Each menu command has a Name property and a Click event, similar to a command button. To create a menu for your form, you will use the Visual Basic Menu Editor, which accessible by pressing < CTRL > + E or Click on Menu Editor Icon.
PARTS OF THE MENU:
Caption - Holds the words you want to appear on the screen.
Name - Indicates the name of the menu control and what the control is referred to by the program. When naming, start out with the prefix, "mnu" . For example, if you had a menu control for "file", you would name it, "mnuFile"
SUBMENU - A list of commands that appear underneath a menu command, (a menu within a menu). To create a submenu, press the right arrow key to move to the next level.
Menu List Box - Shows the list of all menu items that have been created and the indication levels. You can move up, down, left and right by clicking on the name of the menu item and then clicking on one of the four arrow buttons.
Separator Bars - A horizontal line that separates one menu from another. To define a separator bar, type a single hyphen ( - ) for the caption and give it a name. Even though you can never reference the separator bar in the code, you still have to give it a name. If you have more than one separator bar, each one has to have a unique name. (mnuSep1, mnuSep2, ...ect.)
Shortcut Keys - You can create a keyboard shortcut key for a menu item when its created. Select a shortcut key for your menu item by selecting it from the list provided. The purpose of the shortcut is to provide an alternative to sorting through menus to perform a single task.
Checked - If you want a check mark to appear next to an item in your menu, you would put a check here. Check marks are normally for options that you want to be toggled on and off.
Enabled - If you want the user to be able to select a menu item, this will be checked. By default, all are enabled. If unchecked, this menu item will be dimmed out. You can also change this property in the actual code (mnuStar.Enabled = False).
Visible - Determines whether a menu item is displayed on the screen or not. If there is a check in this check box, the menu item will be displayed on the screen. If the box is not checked, the menu item will not be displayed. This property can also be changed in the actual code (mnuStar.Visible = True).
Insert - Click on this if you want to insert an item into the middle of a menu. The item will be inserted at the location of the current item. All items below that point will be moved down.
Delete - Will delete the highlighted menu. Cancel will close the menu editor without saving changes, and OK will save changes to the menu and close the menu editor.
Combo Box - A type of control used to hold a list of items from which the user selects one from a pull down menu.
Differences between a List Box and a Combo Box:
Like list boxes, items can be added to a combo box in two ways...
ADDING ITEMS TO THE LIST USING THE LIST PROPERTY:
ADDING ITEMS TO THE LIST USING THE ADDITEM PROPERTY:
< object_name > .AddItem " < Value > "
ADDING ITEMS INTO THE ItemData ARRAY:
< object_name > .AddItem " < Value > "
< object_name > .ItemData(< object_name > .NewIndex) = < Value >
ADDING ITEMS TO THE LIST:
The code below will add items into the list of a Combo Box:
Harvard will have the index of 0, Yale of 1 and so on
Entering Items into the ItemData array of a Combo Box...
The Text property refers to the actual item that is currently selected in the list.
< label > = < control > .Text
ListIndex works as the same as List Boxes. Same as NewIndex, ItemData, Sorted, Clear, RemoveItem, ListCout...ect.
When naming Combo Boxes, use the prefix, "cbo". For example, if you wanted a combo box named School, you would name it, cboSchool.
QBCOLOR - is a built-in function in VB that will display 15 different colors. The QBCOLOR function has one argument, which is the index of the color to be displayed. The index can range from values 0 to 15. What the heck, here are the values for you: