Presentation is loading. Please wait.

Presentation is loading. Please wait.

VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.

Similar presentations


Presentation on theme: "VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming."— Presentation transcript:

1

2 VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming model.

3 PROCEDURAL V. EVENT- DRIVEN PROGRAMMING Procedural Applications Application execution starts with the first line of code, and follows a predefined path through the application Event-Driven Applications Runs different code sections in response to events. Events can be triggered by the user's actions. The sequence of events determines the sequence in which the code runs. Therefore, the path through the application's code differs each time the program runs.

4 VISUAL BASIC EXAMPLE

5 VISUAL BASIC WINDOW Menu Bar Tool Bar Tool Box Project Explorer Window Properties Window Form Layout Window

6 STEPS TO CREATE AN APPLICATION IN VISUAL BASIC 1.Create the user interface of the application. 2.Write code that responds to actions taken in the user interface.

7 DEMONSTRATION

8 ADDING A LABEL OBJECT Is used to display information Label Properties: Name: - identifies an object - begin object name with lbl Caption:- changes the text displayed in the label Font:- changes the font, style and size Alignment: - can be set to left, right or center LABEL

9 ADDING A COMMAND BUTTON Is something the user can click on Label Properties: Name: - begin object name with cmd Caption:- changes the text displayed in the command button Command Button

10 FORM PROPERTIES An object used to hold other objects Name – begin form objects with frm Caption – changes the text displayed in the title bar

11 EXERCISE GO TO PAGE 3-6 WORK ON REVIEW NO. 2

12 PROGRAM CODE Is a set of instructions that tells the computer how to perform a specific task

13 EVENT PROCEDURE Is a block of code that executes in response to an event (ex. a mouse click) Ex. Done Command Button –Unload form name or Unload Me

14 EXERCISE GO TO PAGE 3-10 WORK ON REVIEW 3 AND 4

15 USING ASSIGNMENT TO CHANGE PROPERTY VALUES LABEL PROPERTIES Caption can be assigned text Font –can change the size Bold and Italic are either True or False can change the font name Alignment can be assigned 0 (left justify), 1 (right justify), or 2 (center) COMMAND BUTTONS Caption can be assigned text FORM PROPERTIES Caption can be assigned text

16 EXAMPLE Private Sub CMDDONE_Click() Unload FRMNAME End Sub Private Sub CMDGORDON_Click() LBLNAME.Caption = "MY NAME IS GORDON" End Sub Private Sub CMDJOHN_Click() LBLNAME.Caption = "MY NAME IS JOHN" End Sub Private Sub CMDMARY_Click() LBLNAME.Caption = "MY NAME IS MARY" End Sub

17 FORM LOAD EVENT PROCEDURE Is executed when a form is loaded into memory (when an application is started). Is an alternative to setting property values in the Properties window Example Private Sub Form_Load() LBLNAME.CAPTION = “MY NAME IS …” LBLNAME.ALIGNMENT = 2 End Sub

18 COMMENTING CODE Comments are used to explain and clarify program code for a human reader Has no effect on the way an application runs Single quotation mark ( ‘ ) must begin a comment

19 EXERCISE GO TO PAGE 3-13 WORK ON REVIEW NO. 5

20 IMAGE OBJECTS Name – begin object name with img Picture – is used to display a dialog box for selecting the graphic Stretch – can be either True or False (True means the image is resized if the image box is resized) Visible – can be either True or False IMAGE

21 EXERCISE GO TO PAGE 3-16 WORK ON REVIEW 6

22 OPERATORS AND EXPRESSIONS Exponentiation (^ ) Multiplication ( *) Division ( / ) Addition ( + ) Subtraction ( - ) BEDMAS Example: lblAnswer.Caption = 3.14 *10 ^ 2

23 CREATING AN EXECUTABLE FILE Visual Basic includes a compiler that translates the program code into a separate executable file An executable file can run without Visual Basic Go to File and then select Make

24 EXERCISE Go to Page 3-18 Complete Review 7 and 8

25 DEFINE THE FOLLOWING TERMS: OOP Project Statement Run time Properties window Project explorer window Code editor window Design Time Form Layout window IDE Interface Tool Box Tool Bar

26 Exercises Go to page 3-23 Begin working on the exercises


Download ppt "VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming."

Similar presentations


Ads by Google