Creating menu in visual basic 6

797 views 13 slides Sep 30, 2021
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Design A Menu in VB 6


Slide Content

by: m. d. aleeman

VB 6 Design A Menu
Step 1: Create a New VB 6 form
Open visual basic 6 and choose “Standard EXE” and your default VB
form will show up. The
next step is to create a rectangle shape from the toolbar on the left
hand side of form. Here are the properties of the form.
Form Name: Menu_Form Caption: Menu Design BackColor :
Highlight Text
Width: 10515Height: 6660
Create a rectangle shape with following properties. Do not change
other properties of shape.
Name : Shape1 Caption: Shape1 Border Width: 5

FormDesign
MenuDesignWithRectangularShape
Step2:CreateMenuForColor
Inthissection,wewillcreateanewmenutoselectacolorfortheshape.
GotoTools>MenuEditororright-clickontheformandselectMenuEditor.
ColorMenu
IntheMenuEditor,youmustenterthevaluesforCaption,Name.Youcanadd
Shortcutifnecessary.SelectNexttoaddanewmenuitemandDeleteto
removeanitemfromthemenu.
Toaddasubmenu,selecttherightarrow(->)ortomovethesubmenu,upand
downarrow.ThenyoumustaddCaption,Name,andShortcutforsubmenu
items.

The final menu look like the following.

Color Menu With Sub Menu Items
Click each of the sub menu item and add following codes.
Private Sub blue_Click()
Shape1.FillColor = RGB(0, 0, 255)
End Sub
Private Sub green_Click()
Shape1.FillColor = RGB(0, 255, 0)
End Sub
Private Sub red_Click()
Shape1.FillColor = RGB(255, 0, 0)
End Sub

Step 3: Create Menu For Shapes
Now that you have created color menu, we must create Shape menu with three
sub menu for Oval, Rectangle, and Square shape.
To create this menu, follow all steps mentioned in step 2. Your Shape menu should
look like the following.
Shape Menu
Now the shape menu with three sub menu look like the following.
Shape Menu with three sub menu items
Add following codes by clicking each of the sub menu items of shape menu.

Private Sub MMenu_Click()
form1.Show
Form2.Visible = False
form1.Visible = True
End Sub
Private Sub Oval_Click()
Shape2.Shape = 3
Shape2.FillColor = RGB(218, 165, 32)
End Sub
Private Sub Rectangle_Click()
Shape2.Shape = 0
Shape2.FillColor = RGB(255, 215, 0)
End Sub

Private Sub Square_Click()
Shape2.Shape=1
Shape2.FillColor=RGB(207,181,59)
End Sub
Step 4: Create Menu to Apply Colors
Inthissection,wecreateourlastmenuitemthatapplythecolorselectedfromthecolor
menu.Supposeyouchoose‘Green‘fromcolormenu.Itwillnotchangethebackground
coloroftheshapeunlessyouchoosethefillstylefromapplycolormenu.
Followstep2tocreateanewmenucalledApplyColor.Themenushouldhavethe
followingsubmenuitems.
ApplyColorMenu
Thefinalmenufortheformwilllooklikethefollowing.LookatthesubmenuforApply
Color.

Sub Menu Items For Apply Color
Add the following codes for each sub menu by clicking on them.
Private Sub Transparent_Click()
Shape2.FillStyle = 1
End Sub
Private Sub Diag_Click()
Shape2.FillStyle = 7
End Sub
Private Sub Solid_Click()
Shape2.FillStyle = 0
End Sub

Testing the Project
Once you have saved your project. It is time to test it.
Color Menu = Choose the color for the shape. e.g Red,
Blue, Green Shape Menu = Choose the shape e.g
Oval, Rectangle, or Square
Apply Color = Apply the chosen color style. e.g
Transparent, or Solid Fill.

Select A Color
Select Oval Shape From Shape Menu Apply Solid Fill of Color
Green
The final step will apply solid fill of selected color green to the
shape. Note that you can change the color, shape, or fill at any
point in the program.
Tags