Introduction to Computing - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to Computing

Description:

How to make our user-interface do something? Visual Basic Events ... Today's Lecture was based on. Scott Warner: Chapter 2: Section 2.1(p48-p50) ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 27
Provided by: surajL
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Computing


1
Introduction to Computing
  • Dr. Nadeem A Khan

2
Lecture 7
3
Announcement
  • New TAs
  • Harris Mukarram
  • Mubashir Amjad Hunain
  • Visit the Website for their office hours

4
How to make our user-interface do something?
5
Visual Basic Events
  • Event Action taken by the user e.g.
  • Clicking a Control
  • Double Clicking a Control
  • Getting Focus
  • Losing Focus
  • etc. etc.

6
Visual Basic Events (Contd.)
  • Naming of Events
  • Clicking a Command Button 1
  • Command1_Click
  • Double Clicking a Picture Box 2
  • Picture2_DblClick
  • Text box 1 gets Focus
  • Text1_GotFocus
  • Text box 1 loses Focus
  • Text1_LostFocus

7
Visual Basic Events (Contd.)
  • Names of events
  • gt objectName_event
  • Events are pre-defined

8
Event Procedure
  • Event Procedure block of code to be executed
    when an event occurs
  • General form
  • Sub objectName_event()
  • statements
  • End Sub

9
Event Procedure (Contd.)
  • E.g
  • Sub Command1_Click()
  • statements
  • End Sub
  • Sub Text1_GotFocus()
  • statements
  • End Sub

10
Statements?
11
VB Statements
  • Statements to change the properties of an object
  • the general form
  • Let objectName.property setting

12
Statements (Contd.)
  • Let objectName.property setting
  • E.g
  • Let Text1.FontSize 12
  • Let Text1.FontBold TRUE
  • Let Text1.Text

13
Event Procedure (Contd.)
  • Event procedure general form
  • Sub objectName_event()
  • statements
  • End Sub
  • Example
  • Sub Command1_Click()
  • Let Text1.text
  • Let Text2.textHello
  • End Sub

14
Viewing Code
Object Box
Procedures List Box
Margin Indicator Bar
Split Bar
Procedure View
Full Module View
15
Methods
  • Another category of statements based on methods

16
Methods (Contd.)
  • E.g
  • Picture1.Cls
  • Clears Picture1 Picture Box
  • Picture1.Print 3
  • Prints 3 in the Picture1 Picture Box

17
Methods (Contd.)
  • General form of these statements
  • gt objectName.Method parameters
  • (if any)

18
The Print Method
  • Picture1.Print m ?
  • Picture1.Print m ?
  • Picture1.Print m n r ?
  • m, n, r are numbers e.g. 3, 5.2

19
Numbers
  • Numeric Constants
  • 2, 5.6, 9, 10.005
  • Arithmetic Operations
  • Addition (23)
  • Subtraction (2-3)
  • Multiplication (23)
  • Division (2/3)
  • Exponentiation (23)

20
Numbers (Contd.)
  • Numeric Expressions
  • e.g.
  • (23)/5
  • (52) (2- 10/2)
  • 2.52-3214/7

21
Numbers (Contd.)
  • How will this be calculated?
  • 210/5
  • 52 2- 1/10
  • 46-325/10
  • 325

22
Numbers (Contd.)
  • Operator Precedence
  • 1.
  • 2.- operator (indicating a negative value)
  • 3. and / operator
  • 4. and - operator

23
Numbers (Contd.)
  • Use parenthesis ( ) to keep intentions clear
  • (22)2 ?
  • 222 ?
  • (5 (52))/(21) ?

24
Strings
  • E.g
  • hello
  • 9/17/95
  • 23

25
What will be printed?
  • Picture1.Print 232
  • Picture1.Print hello
  • Picture1.Print 232

26
Todays Lecture was based on
  • David Schneider
  • Chapter 3 Section 3.2
  • Scott Warner
  • Chapter 2 Section 2.1(p48-p50)
  • Chpater5 Section 5.2
Write a Comment
User Comments (0)
About PowerShow.com