SlideShare a Scribd company logo
CIS-160
Final Review
Final Exam


100 points
Open book, open notes
True/false, multiple choice, fill-in, short answer
Variables and Constants


Variable: Memory locations that hold data that can be
changed during project execution
  Example: customer’s name
Named Constant: Memory locations that hold data
that cannot be changed during project execution
  Example: sales tax rate
Using Variables and Constants


In Visual Basic when you declare a Variable or Named
Constant
  An area of memory is reserved
  A name is assigned called an Identifier
Declaration Statements


Assign name and data type
Not executable statements unless a value is assigned
on same line
Naming Variables & Constants


Must follow Visual Basic Naming Rules
  Cannot use reserved words or keywords that Basic has
  assigned a meaning such as print, name, and value
  Must begin with a letter and no spaces or periods
Should follow Naming Conventions
  Names should be meaningful
  Include class (data type) of variable in name
Use mixed case for variables and uppercase for
constants
Scope and Lifetime of Variables


 Visibility of a variable is its scope
   Where is that identifier valid?
 Scope may be
   Namespace: throughout project
   Module: within current form/class
   Local: within a procedure
   Block: within a portion of a procedure
 Lifetime of a variable is the period of time the variable
 exists
Static Variables


Use static to declare local and block level variables
that need to retain their value
Variable will not be initialized next time procedure
runs, and will have last value assigned
If the variable is used in multiple procedures, declare
it at the module level with private
  Pass data as arguments if one procedure calls the other
Converting Strings to Numeric Values


  Use Parse methods to convert a string to its numeric
  value before it’s used in a calculation
  Each numeric data type class has a Parse method
  Parse method returns a value that can be used in
  calculations
  Parse method fails if user enters nonnumeric data,
  leaves data blank, or entry exceeds data type size
Try/Catch Blocks


Enclose statements that might cause a run-time error
within Try/Catch block
If an exception occurs while statements in the Try
block are executing, code execution is moved to the
Catch Block
If a Finally statement is included, the code in that
section executes last, whether or not an exception
occurred
Using Overloaded Methods


This OOP feature allows the Messagebox Show
method to act differently for different arguments
Each argument list is called a signature: the Show
method has multiple signatures
Supplied arguments must exactly match one of the
signatures provided by the method
If Statements


Used to make decisions
If true, only the Then clause is executed; if false, only
Else clause is executed (if there is an Else)
Block If…Then…Else must always conclude with End
If
Then must be on same line as If or ElseIf
End If and Else appear alone on a line
Conditions


Test in an If statement is typically based on a
condition
Six relational operators are used for comparison of
numbers, dates, and text
  Equal sign is used to test for equality
Strings are compared using ANSI value of each
character
  CIS is less than CNA
  MATH is less than MATH&
Combining Logical Operators


Compound conditions can combine multiple logical
conditions
  And describes conditions where both tests are true
  Or describes conditions where either or both tests are
  true
When both And and Or are evaluated And is
evaluated before the Or
  Use parenthesis to change the order of evaluation
Input Validation


Check to see if valid values were entered or available
Can check for a range of values (often called
“reasonableness”)
If Integer.Parse(scoreTextBox.Text) >= 0 Then
              ‘ Code to perform calculations….
Check for a required field (not blank)
If studentIDTextBox.Text <> "" Then ...
Select Case


Use Select Case to test one value for different
matches (“cases”)
Usually simpler and clearer than nested If
No limit to number of statements that follow a Case
statement
When using a relational operator must use the word
Is
Use the word “To” to indicate a range with two
endpoints
Sharing an Event Procedure


Add object/event combinations to the Handles clause
at the top of an event procedure
Allows the procedure to be associated with different
events or other controls
Sender argument identifies which object had the
event happen
Cast (convert) sender to a specific object type using
the CType function
Calling Event Procedures


Calling an event procedure allows reuse of code
[Call] ProcedureName (arguments)
  Keyword Call is optional and rarely used
Examples
Call clearButton_Click (sender, e)
--OR--
clearButton_Click (sender, e)
Breakpoints


Breakpoints allow you to follow the execution of your
code while program is running
  Can hover the cursor over a variable or property to see
  the current value in the current procedure
  Can execute each line, skip procedures
Can use Console.Writeline to output values to track
code execution
Variables and property values can be seen in different
windows (autos, locals) while code is executing
Writing Procedures


A general procedure is reusable code which can be
called from multiple procedures
Useful for breaking down large sections of code into
smaller units
Two types:
  Sub Procedure performs actions
  Function Procedure performs actions AND returns a
  value (the return value)
Passing Arguments to Procedures


  If a procedure includes an argument, any call to the
  procedure must supply a value for the argument
    Number of arguments, sequence and data type must match
  Arguments are passed one of two ways:
    ByVal – Sends a copy of the argument’s value, original cannot
    be altered
    ByRef - Sends a reference to the memory location where the
    original is stored and the procedure may change the
    argument’s original value
    If not specified, arguments are passed by value
Modal versus Modeless Forms


Show method displays a form as modeless - means
that both forms are open and the user can move from
one form to the other
ShowDialog method displays a new form as modal -
the user must close the form in order to return to the
original form
  No other program code in the original form can execute
  until the user responds to and hides or closes the modal
  form
ListBoxes and ComboBoxes


Provide the user with a list of choices to select from
Various styles of display, choose based on
  Space available
  Need to select from an existing list
  Need to add to a list
Listboxes and comboboxes share most of the same
properties and operate in a similar way
  Combo box control has a DropDown Style property
  Combo box allows text entry
The Items Collection


List of items in a ListBox or ComboBox is a collection
  Collection is group of like objects
  Items referenced by number (zero-based)
Collections are objects that have properties and
methods that allow
  Adding items
  Removing items
  Referring to an individual element/member
  Counting items
SelectedIndex


Index number of currently selected item is stored in
the SelectedIndex property
  Property is zero-based
  If no list item is selected, SelectedIndex property is
  negative 1 (-1)
Use to select an item in list or deselect all items
Do Loops


A loop repeats a series of instructions
An iteration is a single execution of the statement(s) in the
loop
Used when the exact number of iterations is unknown
A Do/Loop terminates based on condition change
Execution of the loop continues while a condition is True or
until a condition is True
The condition can be placed at the top or the bottom of
the loop
Pretest vs. Posttest


Pretest: test before enter loop
  loop may never be executed since test executes
  BEFORE entering loop
  Do While … Loop
  Do Until … Loop
Posttest: test at end of loop
  loop will always be executed at least once
  Do … Loop While
  Do … Loop Until
For/Next Loops


Used to repeat statements in a loop a specific number of
times
Uses a numeric counter variable called Counter or Loop
Index
  Counter is incremented at the bottom of the loop on each
  iteration
Start value sets initial value for counter
End value sets final value for counter
Step value can be included to specify the incrementing
amount
  Step can be a negative number
For/Each Loops


Used to repeat statements for each member of a
group
A reference variable is used to “point” to each item
Must be the data type of each item in group
Exiting Loops


In some situations you may need to exit the loop early
Use the Exit For or Exit Do statement inside the loop
Typically used in an If statement (some condition
determines whether to exit the loop or not)
Arrays


List or series of variables all referenced by the same
name
  Similar to list of values for list boxes and combo boxes,
  without the box
  Each variable is distinguished by an index
  Each variable is the same data type
Individual elements are treated the same as any other
individual variable
Array Terms


Element: Individual item in the array
Subscript (or index): Zero-based identifier used to
reference the specific elements in the array
  Must be an integer
Subscript Boundaries
  Lower Subscript, 0 by default
  Upper Subscript
Subscripts


Subscripts may be constants, variables, or numeric
expressions
Subscripts must be integers
Subscripts begin at zero (0)
VB throws exceptions for subscripts that are out of
range (upper and lower bounds).

More Related Content

PPT
Ap Power Point Chpt5
PDF
Istqb ctfl-series - Black Box Testing
PPT
Ap Power Point Chpt3
PPT
Equivalence partitions analysis
PPTX
Module 9 : using reference type variables
Ap Power Point Chpt5
Istqb ctfl-series - Black Box Testing
Ap Power Point Chpt3
Equivalence partitions analysis
Module 9 : using reference type variables

What's hot (20)

PPTX
Chapter 3.4
PPTX
Type checking compiler construction Chapter #6
PDF
Compiler Construction | Lecture 7 | Type Checking
PPTX
Module 4 : methods & parameters
PPT
Boundary value analysis
PPTX
PPT
Basic of java 2
PPTX
EquivalencePartition
PPTX
Test design techniques
PPT
Type Checking(Compiler Design) #ShareThisIfYouLike
PDF
Type Checking
PDF
Equivalence partitioning
PPT
Introduction to objects and inputoutput
PPTX
Computer programming - variables constants operators expressions and statements
PPT
9 case
PPTX
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
PDF
JetBrains MPS: Editor Aspect
PDF
Test design techniques
Chapter 3.4
Type checking compiler construction Chapter #6
Compiler Construction | Lecture 7 | Type Checking
Module 4 : methods & parameters
Boundary value analysis
Basic of java 2
EquivalencePartition
Test design techniques
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking
Equivalence partitioning
Introduction to objects and inputoutput
Computer programming - variables constants operators expressions and statements
9 case
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
JetBrains MPS: Editor Aspect
Test design techniques
Ad
Ad

Similar to CIS160 final review (20)

PPS
Procedures functions structures in VB.Net
PPTX
Variables and calculations_chpt_4
PPT
Chapter2pp
PDF
Ma3696 Lecture 3
PPTX
Unit 1 introduction to visual basic programming
PPT
Chapter 03
DOCX
C# language basics (Visual Studio)
DOCX
C# language basics (Visual studio)
PPTX
Advanced VB: Review of the basics
PPTX
Advanced VB: Review of the basics
PPT
VB.net
PPTX
JAVA METHOD AND FUNCTION DIVIDE AND SHORT.pptx
PPTX
Data weave (MuleSoft)
PPT
Chapter 07
PDF
Suncoast Credit Union and Armwood High School - UiPath automation developer s...
Procedures functions structures in VB.Net
Variables and calculations_chpt_4
Chapter2pp
Ma3696 Lecture 3
Unit 1 introduction to visual basic programming
Chapter 03
C# language basics (Visual Studio)
C# language basics (Visual studio)
Advanced VB: Review of the basics
Advanced VB: Review of the basics
VB.net
JAVA METHOD AND FUNCTION DIVIDE AND SHORT.pptx
Data weave (MuleSoft)
Chapter 07
Suncoast Credit Union and Armwood High School - UiPath automation developer s...

More from Randy Riness @ South Puget Sound Community College (20)

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
master seminar digital applications in india
PDF
Business Ethics Teaching Materials for college
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Classroom Observation Tools for Teachers
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Types and Its function , kingdom of life
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Microbial diseases, their pathogenesis and prophylaxis
FourierSeries-QuestionsWithAnswers(Part-A).pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
master seminar digital applications in india
Business Ethics Teaching Materials for college
PPH.pptx obstetrics and gynecology in nursing
VCE English Exam - Section C Student Revision Booklet
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
O7-L3 Supply Chain Operations - ICLT Program
Classroom Observation Tools for Teachers
TR - Agricultural Crops Production NC III.pdf
Insiders guide to clinical Medicine.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Types and Its function , kingdom of life
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

CIS160 final review

  • 2. Final Exam 100 points Open book, open notes True/false, multiple choice, fill-in, short answer
  • 3. Variables and Constants Variable: Memory locations that hold data that can be changed during project execution Example: customer’s name Named Constant: Memory locations that hold data that cannot be changed during project execution Example: sales tax rate
  • 4. Using Variables and Constants In Visual Basic when you declare a Variable or Named Constant An area of memory is reserved A name is assigned called an Identifier
  • 5. Declaration Statements Assign name and data type Not executable statements unless a value is assigned on same line
  • 6. Naming Variables & Constants Must follow Visual Basic Naming Rules Cannot use reserved words or keywords that Basic has assigned a meaning such as print, name, and value Must begin with a letter and no spaces or periods Should follow Naming Conventions Names should be meaningful Include class (data type) of variable in name Use mixed case for variables and uppercase for constants
  • 7. Scope and Lifetime of Variables Visibility of a variable is its scope Where is that identifier valid? Scope may be Namespace: throughout project Module: within current form/class Local: within a procedure Block: within a portion of a procedure Lifetime of a variable is the period of time the variable exists
  • 8. Static Variables Use static to declare local and block level variables that need to retain their value Variable will not be initialized next time procedure runs, and will have last value assigned If the variable is used in multiple procedures, declare it at the module level with private Pass data as arguments if one procedure calls the other
  • 9. Converting Strings to Numeric Values Use Parse methods to convert a string to its numeric value before it’s used in a calculation Each numeric data type class has a Parse method Parse method returns a value that can be used in calculations Parse method fails if user enters nonnumeric data, leaves data blank, or entry exceeds data type size
  • 10. Try/Catch Blocks Enclose statements that might cause a run-time error within Try/Catch block If an exception occurs while statements in the Try block are executing, code execution is moved to the Catch Block If a Finally statement is included, the code in that section executes last, whether or not an exception occurred
  • 11. Using Overloaded Methods This OOP feature allows the Messagebox Show method to act differently for different arguments Each argument list is called a signature: the Show method has multiple signatures Supplied arguments must exactly match one of the signatures provided by the method
  • 12. If Statements Used to make decisions If true, only the Then clause is executed; if false, only Else clause is executed (if there is an Else) Block If…Then…Else must always conclude with End If Then must be on same line as If or ElseIf End If and Else appear alone on a line
  • 13. Conditions Test in an If statement is typically based on a condition Six relational operators are used for comparison of numbers, dates, and text Equal sign is used to test for equality Strings are compared using ANSI value of each character CIS is less than CNA MATH is less than MATH&
  • 14. Combining Logical Operators Compound conditions can combine multiple logical conditions And describes conditions where both tests are true Or describes conditions where either or both tests are true When both And and Or are evaluated And is evaluated before the Or Use parenthesis to change the order of evaluation
  • 15. Input Validation Check to see if valid values were entered or available Can check for a range of values (often called “reasonableness”) If Integer.Parse(scoreTextBox.Text) >= 0 Then ‘ Code to perform calculations…. Check for a required field (not blank) If studentIDTextBox.Text <> "" Then ...
  • 16. Select Case Use Select Case to test one value for different matches (“cases”) Usually simpler and clearer than nested If No limit to number of statements that follow a Case statement When using a relational operator must use the word Is Use the word “To” to indicate a range with two endpoints
  • 17. Sharing an Event Procedure Add object/event combinations to the Handles clause at the top of an event procedure Allows the procedure to be associated with different events or other controls Sender argument identifies which object had the event happen Cast (convert) sender to a specific object type using the CType function
  • 18. Calling Event Procedures Calling an event procedure allows reuse of code [Call] ProcedureName (arguments) Keyword Call is optional and rarely used Examples Call clearButton_Click (sender, e) --OR-- clearButton_Click (sender, e)
  • 19. Breakpoints Breakpoints allow you to follow the execution of your code while program is running Can hover the cursor over a variable or property to see the current value in the current procedure Can execute each line, skip procedures Can use Console.Writeline to output values to track code execution Variables and property values can be seen in different windows (autos, locals) while code is executing
  • 20. Writing Procedures A general procedure is reusable code which can be called from multiple procedures Useful for breaking down large sections of code into smaller units Two types: Sub Procedure performs actions Function Procedure performs actions AND returns a value (the return value)
  • 21. Passing Arguments to Procedures If a procedure includes an argument, any call to the procedure must supply a value for the argument Number of arguments, sequence and data type must match Arguments are passed one of two ways: ByVal – Sends a copy of the argument’s value, original cannot be altered ByRef - Sends a reference to the memory location where the original is stored and the procedure may change the argument’s original value If not specified, arguments are passed by value
  • 22. Modal versus Modeless Forms Show method displays a form as modeless - means that both forms are open and the user can move from one form to the other ShowDialog method displays a new form as modal - the user must close the form in order to return to the original form No other program code in the original form can execute until the user responds to and hides or closes the modal form
  • 23. ListBoxes and ComboBoxes Provide the user with a list of choices to select from Various styles of display, choose based on Space available Need to select from an existing list Need to add to a list Listboxes and comboboxes share most of the same properties and operate in a similar way Combo box control has a DropDown Style property Combo box allows text entry
  • 24. The Items Collection List of items in a ListBox or ComboBox is a collection Collection is group of like objects Items referenced by number (zero-based) Collections are objects that have properties and methods that allow Adding items Removing items Referring to an individual element/member Counting items
  • 25. SelectedIndex Index number of currently selected item is stored in the SelectedIndex property Property is zero-based If no list item is selected, SelectedIndex property is negative 1 (-1) Use to select an item in list or deselect all items
  • 26. Do Loops A loop repeats a series of instructions An iteration is a single execution of the statement(s) in the loop Used when the exact number of iterations is unknown A Do/Loop terminates based on condition change Execution of the loop continues while a condition is True or until a condition is True The condition can be placed at the top or the bottom of the loop
  • 27. Pretest vs. Posttest Pretest: test before enter loop loop may never be executed since test executes BEFORE entering loop Do While … Loop Do Until … Loop Posttest: test at end of loop loop will always be executed at least once Do … Loop While Do … Loop Until
  • 28. For/Next Loops Used to repeat statements in a loop a specific number of times Uses a numeric counter variable called Counter or Loop Index Counter is incremented at the bottom of the loop on each iteration Start value sets initial value for counter End value sets final value for counter Step value can be included to specify the incrementing amount Step can be a negative number
  • 29. For/Each Loops Used to repeat statements for each member of a group A reference variable is used to “point” to each item Must be the data type of each item in group
  • 30. Exiting Loops In some situations you may need to exit the loop early Use the Exit For or Exit Do statement inside the loop Typically used in an If statement (some condition determines whether to exit the loop or not)
  • 31. Arrays List or series of variables all referenced by the same name Similar to list of values for list boxes and combo boxes, without the box Each variable is distinguished by an index Each variable is the same data type Individual elements are treated the same as any other individual variable
  • 32. Array Terms Element: Individual item in the array Subscript (or index): Zero-based identifier used to reference the specific elements in the array Must be an integer Subscript Boundaries Lower Subscript, 0 by default Upper Subscript
  • 33. Subscripts Subscripts may be constants, variables, or numeric expressions Subscripts must be integers Subscripts begin at zero (0) VB throws exceptions for subscripts that are out of range (upper and lower bounds).