Presentation is loading. Please wait.

Presentation is loading. Please wait.

Event Driven Programming

Similar presentations


Presentation on theme: "Event Driven Programming"— Presentation transcript:

1 Event Driven Programming
P.J.Balakumaran, A.P, SNMV CAS

2 Event Driven Programming
Visual Basic programs are built around events. Events are various things that can happen in a program. The program statements are executed only when a particular event calls a specific part of the code that is assigned to the event. P.J.Balakumaran, A.P, SNMV CAS

3 Cont…. The TextBox control supports various events such as Change, Click, MouseMove. The code entered in the Change event fires when there is a change in the contents of the TextBox The Click event fires when the TextBox control is clicked. The MouseMove event fires when the mouse is moved over the TextBox P.J.Balakumaran, A.P, SNMV CAS

4 Text Events Click the Textbox Visual Basic 6.0
P.J.Balakumaran, A.P, SNMV CAS Visual Basic 6.0

5 E-D-P An event procedure is the place in your project where you put the code that will run when an event occurs. Double-clicking the object Selecting the object with the mouse and pressing F7 Selecting the object and choosing Code from the View menu Selecting the object's form in the Project Explorer, clicking the View Code button, and choosing the object from the Code window P.J.Balakumaran, A.P, SNMV CAS

6 Event-Driven-Program
Visual Basic automatically generates an event procedure; Private sub command1_click() Text1.font.bold= true End Sub It will display a dialog when the user clicks the CommandButton Event-Driven-Program P.J.Balakumaran, A.P, SNMV CAS BOLD

7 Example MoveIt consists of the form frmMove, Actions
Four CommandButtons placed in its corners. When you run MoveIt, clicking one of these buttons will move the form to the corresponding corner of the screen. P.J.Balakumaran, A.P, SNMV CAS

8 Create MoveIt Create the graphical user interface (GUI).
Program the Form_Load() event procedure. Program the Click() event procedures. Add the event notification. P.J.Balakumaran, A.P, SNMV CAS

9 Four Command Buttons Top Left Bottom Left Top Right Bottom Right
P.J.Balakumaran, A.P, SNMV CAS Top Right Bottom Right

10 Programming the Form_Load()
form1.Left = (Screen.Width – form1.Width) / 2 form1.Top = (Screen.Height – form1.Height) / 2 Command Button 1 -cmdBottomLeft_Click frmMove.Top = Screen.Height - frmMove.Height frmMove.Left = 0 P.J.Balakumaran, A.P, SNMV CAS

11 Command Button 2-cmdBottomRight
frmMove.Top = Screen.Height - frmMove.Height frmMove.Left = Screen.Width - frmMove.Width Command Button 3- cmdTopLeft frmMove.Top = 0 frmMove.Left = 0 Command Button 4- cmdTopRight P.J.Balakumaran, A.P, SNMV CAS

12 EXE Top Left Bottom Left Top Right Bottom Right
P.J.Balakumaran, A.P, SNMV CAS Top Right Bottom Right


Download ppt "Event Driven Programming"

Similar presentations


Ads by Google