![Page 1: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/1.jpg)
Catalog guidelines of 3-4 hours per week per unit
![Page 2: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/2.jpg)
CS 14 Final Grade vs. Class Attendance, Win/Spr 2004
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Class Attendance
AB
C
D
![Page 3: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/3.jpg)
Operators in VB: Part IOperators in VB: Part I
Symbol Name
^ Exponentiation* Multiplication/ Division + Addition - Subtraction
We have seen 5 arithmetic operators
![Page 4: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/4.jpg)
Operators in VB: Part IIOperators in VB: Part II
Symbol Name
= Equality < > Inequality ()< Less Than> Greater Than<= Less Than or Equal To () >= Greater Than or Equal To ()
We have seen 6 relational operators
![Page 5: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/5.jpg)
Operators in VB: Part IIIOperators in VB: Part III
Symbol Name
Not Negation And ConjunctionOr Disjunction
We have seen 3 Boolean operators
![Page 6: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/6.jpg)
Operators in VB: Part IIIIOperators in VB: Part IIII
Symbol Name
& Concatenation
We have seen 1 string operator
![Page 7: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/7.jpg)
Operands in VB: Part IOperands in VB: Part I
Examples of arithmetic operands
5 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
![Page 8: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/8.jpg)
Operands in VB: Part IIOperands 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
![Page 9: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/9.jpg)
Operands in VB: Part IIIOperands 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
![Page 10: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/10.jpg)
Expressions In VB: Part IExpressions 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
![Page 11: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/11.jpg)
Expressions In VB: Part IIExpressions 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
![Page 12: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/12.jpg)
Expressions In VB: Part IIIExpressions 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”
![Page 13: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/13.jpg)
Expressions In VB: Part IIIIExpressions 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
![Page 14: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/14.jpg)
Expressions In VB: Part VExpressions In VB: Part VExpressions 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
![Page 15: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/15.jpg)
Expressions In VB: Part VIExpressions In VB: Part VIExpressions consist of one or more operands and zero or more operators.
Expressions always evaluate to a single value
Expression Evaluates to
2 > 1 True
2 < 1 False
(2 > 1) True
2 >= 1 True
(2 >= 2) True
(2 = 2) True
![Page 16: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/16.jpg)
Expressions In VB: Part VIIExpressions In VB: Part VIIExpressions 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
![Page 17: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/17.jpg)
Expressions In VB: Part VIIIExpressions In VB: Part VIIIExpressions 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
![Page 18: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/18.jpg)
Expressions In VB: Part IXExpressions In VB: Part IXExpressions consist of one or more operands and zero or more operators.
Expressions always evaluate to a single value
Expression Evaluates to
True And (2 > 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
![Page 19: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/19.jpg)
Not((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
![Page 20: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/20.jpg)
Expressions In VB: Part XExpressions In VB: Part XExpressions 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
![Page 21: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/21.jpg)
Expressions In VB: Part XIExpressions In VB: Part XIExpressions 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 > 11) True
Dim shtX As Short
shtX = 0
(11 / shtAge) * 10 Runtime Error
![Page 22: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/22.jpg)
Expressions In VB: Part XIIExpressions In VB: Part XIIExpressions 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”
![Page 23: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/23.jpg)
Expressions In VB: Part XIIIExpressions In VB: Part XIIIExpressions 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 > 2)) False
Dim shtS As String
shtS = “Lisa”
“Lisa” < “Bart” False
![Page 24: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/24.jpg)
HomeworkRead 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
![Page 25: Catalog guidelines of 3-4 hours per week per unit](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814c1f550346895db9234b/html5/thumbnails/25.jpg)
Joe 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 * 3End Sub
Private Sub btnCalculate_Click(... Dim shtVariable As Integer
shtVariable = 10000 shtVariable = shtVariable * 3End 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
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)