Introduction to Computing - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Introduction to Computing

Description:

value is used to display the corresponding character in the Text1 at the end of this procedure ... Usage: Same as Integer Type except the range is. positive and ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 35
Provided by: surajL
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Computing


1
Introduction to Computing
  • Dr. Nadeem A Khan

2
Lecture 10
3
The Keypress Event Procedure
  • Sub Text1_KeyPress(KeyAscii as Integer)
  • statements
  • End Sub
  • Text1_KeyPress event will occur when
  • Text1 has the focus and a key is pressed

4
The Keypress Event Procedure (Contd.)
  • Sub Text1_KeyPress(KeyAscii as Integer)
  • statements
  • End Sub
  • Keyascii
  • is a variable (of type Integer)
  • gets the ANSI value of the pressed key
  • value is used to display the corresponding
    character in the Text1 at the end of this
    procedure

5
The Keypress Event Procedure (Contd.)
  • What will happen in these cases?
  • Sub Text1_KeyPress(KeyAscii as Integer)
  • Let KeyAscii 65
  • End Sub
  • Sub Text1_KeyPress(KeyAscii as Integer)
  • Let KeyAscii 0
  • End Sub

6
Data Types
  • Already known
  • String
  • Single
  • Integer

7
Data Types (Contd.)
  • Strings
  • Storage 10 bytes string length
  • Range 0 to app. 2 billions chars.
  • Declaration
  • Dim strVarLen As String
  • (declares a string of a variable length)

8
Data Types (Contd.)
  • Fixed-Length Strings
  • Storage Length of string
  • Range 1 to app. 65, 400 chars.
  • Declaration
  • Dim strFixLen As String 2
  • (declares a string of a fix size of 2 chars.)

9
Data Types
  • Fixed-Length Strings
  • Usage
  • Example
  • Dim strText As String 5
  • Let strText Hello
  • Picture1.Print strText
  • Let strText H
  • Picture1.Print strText
  • Let strText HelloWorld
  • Picture1.Print strText

10
Data Types
  • Fixed-Length Strings
  • Usage
  • Result
  • Hello (Complete string)
  • H. (H followed 4 spaces)
  • Hello (First 5 characters only)
  • gt The length is fix

11
Data Types (Contd.)
  • Integers
  • Storage 2 bytes
  • Range -32,768 to 32,767
  • Declaration
  • Dim intExample As Integer
  • (declares intExample as an Integer variable)

12
Data Types
  • Integers
  • Usage
  • Example
  • Dim count As Integer
  • Let count 6
  • Picture1.Print count
  • Let count count1
  • Picture1.Print count
  • Let count 6/5
  • Picture1.Print count
  • Let count 2.33333 2
  • Picture1.Print count

13
Data Types
  • Integer
  • Usage
  • Result
  • 6
  • 7
  • 1 (rounding to lower value)
  • 5 (rounding to higher value)
  • gt takes only whole number values

14
Data Types (Contd.)
  • Long (Integer)
  • Storage 4 bytes
  • Range -2,147,483,648 to 2,147,483,647
  • Declaration
  • Dim lngExample As Long
  • (declares lntExample as a long variable)

15
Data Types (Contd.)
  • Long (Integer)
  • Usage Same as Integer Type except the range is
  • much larger

16
Data Types (Contd.)
  • Byte
  • Storage 1 byte
  • Range 0 to 255
  • Declaration
  • Dim bytExample As Byte
  • (declares bytExample as a Byte type variable)

17
Data Types (Contd.)
  • Byte
  • Usage Same as Integer Type except the range is
  • positive and much smaller

18
Data Types (Contd.)
  • Boolean
  • Storage 2 bytes
  • Range TRUE(1) or FALSE(0)
  • Declaration
  • Dim blnState As Boolean
  • (declares a Boolean type variable blnState)

19
Data Types (Contd.)
  • Boolean
  • Usage
  • Example
  • Dim blnExample As Boolean
  • Let blnExample FALSE
  • Picture1.Print blnExample
  • Let blnExample 1
  • Picture1.Print blnExample
  • Let blnExample 6
  • Picture1.Print blnExample
  • Let blnExample -875.2
  • Picture1.Print blnExample

20
Data Types (Contd.)
  • Boolean
  • Usage
  • Example
  • FALSE
  • TRUE
  • TRUE
  • TRUE
  • gtValues other than 0 are TRUE

21
Data Types (Contd.)
  • Single (Precision Floating-Point)
  • Storage 4 bytes
  • Range -3.4E38 to -1.4E-45 (negative)
  • 1.4E-45 to 3.4E38 (positive)
  • Declaration
  • Dim sngAverage As Single
  • (declares a Single type variable sngAverage)

22
Data Types (Contd.)
  • Double (Precision Floating-Point)
  • Storage 8 bytes
  • Range -1.7E308 to -4.9E-324 (negative)
  • 4.9E-324 to 1.7E308 (positive)
  • Declaration
  • Dim dblAverage As Double
  • (declares a Double type variable dblAverage)

23
Data Types (Contd.)
  • Double
  • Usage
  • Example
  • Dim sngValue As Single, dblValue As Double
  • Let sngValue 1/3
  • Picture1.Print sngValue
  • Let dblValue 1/3
  • Picture1.Print dblValue

24
Data Types (Contd.)
  • Double
  • Usage
  • Result
  • 0.3333333 (Single precision)
  • 0.333333333333333 (Double precision)
  • gt Value of 1/3 represented more accurately
  • by double than by single

25
Data Types (Contd.)
  • Double
  • Usage
  • Example
  • Dim sngValue As Single, dblValue As Double
  • Let sngValue 1/3
  • Let sngValue sngValue 100000
  • Picture1.Print sngValue
  • Let dblValue 1/3
  • Let dblValue dblValue 100000
  • Picture1.Print dblValue

26
Data Types (Contd.)
  • Double
  • Usage
  • Result
  • 33333.34 (Single precision rounding error)
  • 33333.3333333333 (Double precision)
  • gt - The decimal point is floating
  • - Eventually both will be subjected to rounding
    errors
  • value increases to large values
  • - Still Double will remain more precise than
    Single

27
Data Types (Contd.)
  • Currency
  • Storage 8 bytes
  • Range -922,337,203,685,477.5808 to
  • 922,337,203,685,477.5807
  • Declaration
  • Dim curRevenue As Currency
  • (declares a Currency type variable curRevenue)

28
Data Types (Contd.)
  • Currency
  • Usage
  • Example
  • Dim curValue As Currency
  • Let curValue 1/3
  • Picture1.Print curValue
  • Let curValue 1001/3
  • Picture1.Print curValue

29
Data Types (Contd.)
  • Currency
  • Usage
  • Result
  • 0.3333 33333.3333
  • gt - The decimal point is NOT floating
  • - Could be used for currency and scientific
    research
  • - No rounding problems for high values

30
Data Types (Contd.)
  • Even more data types
  • Date Variable for date and time
  • Object Variable
  • Variant Variable
  • .
  • Read the book for more info.

31
More on Operators
  • Not only ,-,,
  • But also
  • \ opeartor e.g 5.1\2.04 2
  • MOD operator e.g 15.2 MOD 63

32
More on Operators (Contd.)
  • Operator Precedence
  • 1.
  • 2.- operator (indicating a negative value)
  • 3. and / operator
  • 4. \ operator
  • 5. MOD operator
  • 6. and - operator

33
Assignment 3
  • Assignment 3 has been posted to the CS101
    Website.
  • The Deadline is on 659 p.m. Wednesday Sept. 25.

34
Reading for today
  • Scott Warner
  • Chapter 2 Section 2.3(p60-p66)
  • Chpater5 Section 5.1
Write a Comment
User Comments (0)
About PowerShow.com