Title: Catalog guidelines of 3-4 hours per week per unit
1Catalog guidelines of 3-4 hours per week per unit
2CS 14 Final Grade vs. Class Attendance, Win/Spr
2004
100
A
90
B
80
C
70
D
60
50
40
30
20
10
0
0
10
20
30
40
50
60
70
80
90
100
Class Attendance
3Operators in VB Part I
Symbol Name Exponentiation
Multiplication / Division Addition -
Subtraction
We have seen 5 arithmetic operators
4Operators in VB Part II
We have seen 6 relational operators
Symbol Name Equality lt gt Inequality
(?) lt Less Than gt Greater Than lt Less Than
or Equal To (?) gt Greater Than or Equal To
(?)
5Operators in VB Part III
We have seen 3 Boolean operators
Symbol Name Not Negation And Conjunction Or
Disjunction
6Operators in VB Part IIII
We have seen 1 string operator
Symbol Name Concatenation
7Operands in VB Part I
Examples of arithmetic operands
- The literal number 5
- -2 The literal number 2
- 12.4 The literal number 12.4
- Dim shtAge As Short The variable shtAge
- Dim lngX As Short The variable lngX
- Const sngTax 1.07 The constant sngTax
8Operands in VB Part II
Examples of string operands
A The literal string A -2
The literal string -2 Homer The
literal string Homer Dim strName As String
The variable strName Dim strQ As String
The variable strQ Const StrM NO
The constant StrM
9Operands in VB Part III
Examples of Boolean operands
True The literal logical value
True False The literal logical value
False Dim blnIsMale As Boolean The variable
blnIsMale
10Expressions In VB Part I
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
1 1
1 1 2
1 1 1 3
11Expressions In VB Part II
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
(1 1 1) 3
(1 1) 3 6
10 / 3 3.333333333
1 1 2
-(1 1) -2
-(-1-1) 2
12Expressions In VB Part III
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Five Five
5 5
(5 5) (5 5)
One Time OneTime
One Time One Time
U (2).ToString U2
13Expressions In VB Part IIII
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Five 5 illegal
5 illegal
- 5 - 5
One 5 illegal
10 / 0 Runtime error
0 / 10 0
14Expressions In VB Part V
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
True True
False False
(True) True
Not(True) False
Not(False) True
Not(Not(False)) False
15Expressions In VB Part VI
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
2 gt 1 True
2 lt 1 False
(2 gt 1) True
2 gt 1 True
(2 gt 2) True
(2 2) True
16Expressions In VB Part VII
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Not(2 12) True
Not(12 12) False
17Expressions In VB Part VIII
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
True And True True
True And False False
False And False False
False Or False False
False Or True True
Not(False Or True) False
18Expressions In VB Part IX
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
True And (2 gt 1) True
True And (2 1) False
(1 1) And (2 1) False
False Or False Or False False
True Or (False And True) True
(True Or False) And True True
19Not((2 3 1 5) And (U 2 U2)) Not((
6 1 5) And (U 2 U2)) Not(( 6
6 ) And (U 2 U2)) Not((
True ) And (U 2 U2)) Not((
True ) And ( U2 U2)) Not((
True ) And ( True
)) Not(( True
)) False
20Expressions In VB Part X
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Dim shtAge As Short shtAge 12 (shtAge 2) 14
Dim shtX As Short shtX 0 (shtAge 11) 10 11
21Expressions In VB Part XI
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Dim shtAge As Short shtAge 12 (shtAge gt 11) True
Dim shtX As Short shtX 0 (11 / shtAge) 10 Runtime Error
22Expressions In VB Part XII
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Dim shtS As String shtS Lisa (shtS) Lisa
Dim shtS As String shtS Lisa shtS Simpson Lisa Simpson
23Expressions In VB Part XIII
Expressions consist of one or more operands and
zero or more operators. Expressions always
evaluate to a single value
Expression Evaluates to
Dim blnB As Boolean blnB False (blnB And (12 gt 2)) False
Dim shtS As String shtS Lisa Lisa lt Bart False
24Homework Read Drills 3.1, 3.2, 3.3, 3.4, 3.5,
3.6, 3.7, 3.8, 3.9, 3.10, 4.1, 4.2, 4.3, 4,4, 4.5
4.6, 4.7, 4.8, 4.9, 4.10, 4.11, 4.13 and 4.14 in
the book (the answers are in the book). Working
in groups of size 1, 2 or 3 Take one question
from (3.1, 3.2, 3.3, 3.4, 3.5) and one from (3.6,
3.7, 3.8, 3.9, 3.10) and one from (4.1, 4.2, 4.3,
4,4, 4.5 4.6) and (4.7, 4.8, 4.9, 4.10, 4.11,
4.13, 4.14 ) and write a new version of it. The
next page shows examples of the type and quality
of work I expect. Homework is due on Friday the
15th
25Joe Doe (SID 23431) and Jane Doe (SID 855675)
Homework 1 1) Drill 3.3 on page 58 is as follows
If the following code were executed, would an
overflow occur? If so, why?
Private Sub btnCalculate_Click(... Dim
shtVariable As Integer shtVariable 10000
shtVariable shtVariable 3 End Sub
Answer An overflow will not occur.
The exercise is suppose to test our knowledge of
the concept of overflowing, which is defined as
attempting to place a value into a variable which
is too small to hold it. In our modification we
have changed the exercise to consider the Long
type, instead of the Integer type, and to
consider the related concept of underflowing.
which is defined as attempting to place a
negative value into a variable whose type cannot
hold such small values. According to the book,
the most negative value a Long can hold is
9,223,372,036,854,775,808. So our example starts
by defining a Long, initializing it to
9,223,372,036,854,775,800, then asking the user
what will happen if we subtract 5, and what will
happen if we subtract another 5. The exercise is
below
If the following code were executed, would an
overflow occur? If so, why?
Private Sub btnCalculate_Click(... Dim LngVar
As Long LngVar 9,223,372,036,854,775,800
LngVar LngVar 5 what happens here?
LngVar LngVar 5 what about here? End Sub
Answer 1 (write an explanation here, ek)