visual basic visual basic is derived from the basic language (beginner’s all-purpose symbolic...
TRANSCRIPT
![Page 1: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/1.jpg)
![Page 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](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/2.jpg)
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.
![Page 3: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/3.jpg)
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.
![Page 4: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/4.jpg)
VISUAL BASIC EXAMPLE
![Page 5: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/5.jpg)
VISUAL BASIC WINDOWMenu Bar
Tool Bar
Tool Box
Project Explorer Window
Properties Window
Form Layout Window
![Page 6: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/6.jpg)
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.
![Page 7: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/7.jpg)
DEMONSTRATION
![Page 8: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/8.jpg)
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
![Page 9: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/9.jpg)
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
![Page 10: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/10.jpg)
FORM PROPERTIES
• An object used to hold other objects
• Name – begin form objects with frm
• Caption – changes the text displayed in the title bar
![Page 11: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/11.jpg)
EXERCISE
• GO TO PAGE 3-6
• WORK ON REVIEW NO. 2
![Page 12: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/12.jpg)
PROGRAM CODE
• Is a set of instructions that tells the computer how to perform a specific task
![Page 13: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/13.jpg)
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
![Page 14: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/14.jpg)
EXERCISE
• GO TO PAGE 3-10
• WORK ON REVIEW 3 AND 4
![Page 15: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/15.jpg)
USING ASSIGNMENT TO CHANGE PROPERTY VALUES
• LABEL PROPERTIESCaption can be assigned textFont – can change the size
Bold and Italic are either True or Falsecan change the font name
Alignment can be assigned 0 (left justify), 1 (right justify), or 2 (center)
• COMMAND BUTTONSCaption can be assigned text
• FORM PROPERTIESCaption can be assigned text
![Page 16: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/16.jpg)
EXAMPLEPrivate 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
![Page 17: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/17.jpg)
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
![Page 18: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/18.jpg)
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
![Page 19: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/19.jpg)
EXERCISE
• GO TO PAGE 3-13
• WORK ON REVIEW NO. 5
![Page 20: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/20.jpg)
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
![Page 21: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/21.jpg)
EXERCISE
• GO TO PAGE 3-16
• WORK ON REVIEW 6
![Page 22: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/22.jpg)
OPERATORS AND EXPRESSIONS
• Exponentiation (^ )• Multiplication ( *)• Division ( / )• Addition ( + )• Subtraction ( - )• BEDMAS• Example: lblAnswer.Caption = 3.14 *10 ^ 2
![Page 23: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/23.jpg)
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
![Page 24: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/24.jpg)
EXERCISE
• Go to Page 3-18
• Complete Review 7 and 8
![Page 25: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/25.jpg)
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
![Page 26: VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming](https://reader035.vdocument.in/reader035/viewer/2022062312/551b3cfd550346ae7a8b4818/html5/thumbnails/26.jpg)
Exercises
• Go to page 3-23
• Begin working on the exercises