P J Balakumaran A P SNMV CAS EVENT
P. J. Balakumaran, A. P, SNMV CAS EVENT DRIVEN PROGRAMMING
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
CONT…. The Text. Box control supports various events such as Change, Click, Mouse. Move. code entered in the Change event fires when there is a change in the contents of the Text. Box � The Click event fires when the Text. Box control is clicked. � The Mouse. Move event fires when the mouse is moved over the Text. Box P. J. Balakumaran, A. P, SNMV CAS � The
TEXT EVENTS Click the Textbox P. J. Balakumaran, A. P, SNMV CAS Visual Basic 6. 0
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 F 7 � 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 �
Visual Basic automatically generates an event procedure; Event-Driven. Program It will display a dialog when the user clicks the Command. Button BOLD P. J. Balakumaran, A. P, SNMV CAS Private sub command 1_click() Text 1. font. bold= true End Sub
EXAMPLE Move. It consists of the form frm. Move, Actions � � Four Command. Buttons placed in its corners. When you run Move. It, clicking one of these buttons will move the form to the corresponding corner of the screen. P. J. Balakumaran, A. P, SNMV CAS
Create Move. It 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 � Create
Four Command Buttons Bottom Left Top Right Bottom Right P. J. Balakumaran, A. P, SNMV CAS Top Left
PROGRAMMING THE FORM_LOAD() Form � form 1. Left Command Button 1 -cmd. Bottom. Left_Click � frm. Move. Top = Screen. Height - frm. Move. Height � frm. Move. Left = 0 P. J. Balakumaran, A. P, SNMV CAS = (Screen. Width – form 1. Width) / 2 � form 1. Top = (Screen. Height – form 1. Height) / 2
Command Button 2 -cmd. Bottom. Right � frm. Move. Top = Screen. Height - frm. Move. Height � frm. Move. Left = Screen. Width - frm. Move. Width Command Button 3 - cmd. Top. Left =0 � frm. Move. Left = 0 Command Button 4 - cmd. Top. Right � frm. Move. Top =0 � frm. Move. Left = Screen. Width - frm. Move. Width P. J. Balakumaran, A. P, SNMV CAS � frm. Move. Top
EXE Bottom Left Top Right Bottom Right P. J. Balakumaran, A. P, SNMV CAS Top Left
- Slides: 12