Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, August 11, 2011

VB-103 : Program Using Menu Bar

Creating a menu and attaching code .
 (Taken from VB-Tutorial CDs ..)


Refer Design a Menu Bar and Create a Menu as per the format given
And , Creating Tool Bar with Click Event 

Select Tools--> Menu Editor and create menus as per given below :






   (A)Program Design : 






(B) Property(Controls Used) :

  • File & Exit are the main menus
  • Two sub menus of File are Colors & Size
  • The sub menu of Color is Set Color
  • The sub menu of Set Color is White , Red & Blue
Note while giving Names (mnucolors,mnusize...etc) .These are important while attaching code to the object.
You can watch this Video to know about adding Menu Bar into our form.


(C) Attaching Code to the Object :



Private Sub Form_Load()
mnuwhite.Enabled = False
mnuwhite.Checked = True
End Sub
Private Sub mnublue_Click()
Form1.BackColor = vbBlue
mnuwhite.Enabled = True
mnuwhite.Checked = False
mnured.Enabled = True
mnured.Checked = False
mnublue.Enabled = False
mnublue.Checked = True
End Sub
Private Sub mnuexit_Click()
End
End Sub
Private Sub mnularge_Click()
Form1.WindowState = 2
End Sub
Private Sub mnured_Click()
Form1.BackColor = vbRed
mnuwhite.Enabled = True
mnuwhite.Checked = False
mnured.Enabled = False
mnured.Checked = True
mnublue.Enabled = True
mnublue.Checked = False
End Sub
Private Sub mnusmall_Click()
Form1.WindowState = 0
End Sub
Private Sub mnuwhite_Click()
Form1.BackColor = vbWhite
mnuwhite.Enabled = False
mnuwhite.Checked = True
mnured.Enabled = True
mnured.Checked = False
mnublue.Enabled = True
mnublue.Checked = False
End Sub



(D) Errors :
If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.
====================================================================

===========================================================

No comments: