200 likes | 372 Views
المحاضرة الرابعة. كيانات برمجة البيزك المرئي Visual Basic Programming Objects By Hitham M. Abo Bakr. In the Previous Lecture s. Events in Programming VB . For Every VB Control a number of events, A programmer can implement some event by writing a code for these events
E N D
المحاضرة الرابعة كيانات برمجة البيزك المرئي Visual Basic Programming Objects By Hitham M. Abo Bakr
Events in Programming VB • For Every VB Control a number of events, A programmer can implement some event by writing a code for these events • To Write event code, we need to open Code Window : • From View -> Code • Or double click on any control in the selected form
Code Window Select Control Select events
Event Procedure • Example: Label1.Caption = "Mouse coordinates are x= " & X & "y= " & Y Call event from another Event Private Sub Command1_Click() Label2.Caption = "The time now is" & Now End Sub Private Sub Form_Click() Command1_Click End Sub
Menus and Toolbars Menu Toolbar Is a simple tool to access the program functionality
Creating Menus To Create Menus in Visual Basic, We use Menu Editor tool “tool ->Menu Editor or Ctrl-E
Build Simple Menu • We need to know what is the : • Caption • Name • Visible • Enable • Shortcut • Insert • Multilevel Menu
Writing Code • The only available event for menu items is the click event • Example
ToolBars To Create a toolbar we have to follow the following steps
Creating Toolbar Steps Example Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Button.Index = 1 Then MsgBox "Button 1 clicked" ElseIfButton.Index = 2 Then MsgBox "Button 2 clicked" ElseIfButton.Index = 3 Then MsgBox "Button 3 clicked“ End If