SlideShare ist ein Scribd-Unternehmen logo
1 von 33
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).

Weitere ähnliche Inhalte

Was ist angesagt?

Chapter 3.4
Chapter 3.4Chapter 3.4
Chapter 3.4sotlsoc
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Daniyal Mughal
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingEelco Visser
 
Module 4 : methods & parameters
Module 4 : methods & parametersModule 4 : methods & parameters
Module 4 : methods & parametersPrem Kumar Badri
 
Boundary value analysis
Boundary value analysisBoundary value analysis
Boundary value analysisVadym Muliavka
 
EquivalencePartition
EquivalencePartitionEquivalencePartition
EquivalencePartitionswornim nepal
 
Test design techniques
Test design techniquesTest design techniques
Test design techniquesBipul Roy Bpl
 
Equivalence partitioning
Equivalence partitioningEquivalence partitioning
Equivalence partitioningSarjana Muda
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput Ahmad Idrees
 
Computer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsComputer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsJohn Paul Espino
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraJaliya Udagedara
 
JetBrains MPS: Editor Aspect
JetBrains MPS: Editor AspectJetBrains MPS: Editor Aspect
JetBrains MPS: Editor AspectMikhail Barash
 

Was ist angesagt? (20)

Chapter 3.4
Chapter 3.4Chapter 3.4
Chapter 3.4
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6
 
Basic
BasicBasic
Basic
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Module 4 : methods & parameters
Module 4 : methods & parametersModule 4 : methods & parameters
Module 4 : methods & parameters
 
Boundary value analysis
Boundary value analysisBoundary value analysis
Boundary value analysis
 
Generics
GenericsGenerics
Generics
 
Basic of java 2
Basic of java  2Basic of java  2
Basic of java 2
 
Ch6
Ch6Ch6
Ch6
 
EquivalencePartition
EquivalencePartitionEquivalencePartition
EquivalencePartition
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Type Checking
Type CheckingType Checking
Type Checking
 
Equivalence partitioning
Equivalence partitioningEquivalence partitioning
Equivalence partitioning
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
 
Computer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsComputer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statements
 
9 case
9 case9 case
9 case
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
 
JetBrains MPS: Editor Aspect
JetBrains MPS: Editor AspectJetBrains MPS: Editor Aspect
JetBrains MPS: Editor Aspect
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 

Andere mochten auch (7)

Cis166 Final Review C#
Cis166 Final Review C#Cis166 Final Review C#
Cis166 Final Review C#
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
 
Cis245 Midterm Review
Cis245 Midterm ReviewCis245 Midterm Review
Cis245 Midterm Review
 
CIS 245 Final Review
CIS 245 Final ReviewCIS 245 Final Review
CIS 245 Final Review
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
3 sql overview
3 sql overview3 sql overview
3 sql overview
 
Normalization
NormalizationNormalization
Normalization
 

Ähnlich wie CIS160 final review (20)

Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
Midterm Winter 10
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
CIS-166 Midterm
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
Procedures functions structures in VB.Net
Procedures  functions  structures in VB.NetProcedures  functions  structures in VB.Net
Procedures functions structures in VB.Net
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
 
SQL Server Stored procedures
SQL Server Stored proceduresSQL Server Stored procedures
SQL Server Stored procedures
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
Ma3696 Lecture 3
Ma3696 Lecture 3Ma3696 Lecture 3
Ma3696 Lecture 3
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
C# language basics (Visual Studio)
C# language basics (Visual Studio) C# language basics (Visual Studio)
C# language basics (Visual Studio)
 
C# language basics (Visual studio)
C# language basics (Visual studio)C# language basics (Visual studio)
C# language basics (Visual studio)
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
VB.net
VB.netVB.net
VB.net
 
CIS 282 Final Review
CIS 282 Final ReviewCIS 282 Final Review
CIS 282 Final Review
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
presentation of java fundamental
presentation of java fundamentalpresentation of java fundamental
presentation of java fundamental
 
Intro to tsql unit 11
Intro to tsql   unit 11Intro to tsql   unit 11
Intro to tsql unit 11
 

Mehr von Randy Riness @ South Puget Sound Community College

Mehr von Randy Riness @ South Puget Sound Community College (20)

SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
CIS145 Final Review
CIS145 Final ReviewCIS145 Final Review
CIS145 Final Review
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
CIS245 sql
CIS245 sqlCIS245 sql
CIS245 sql
 
CSS
CSSCSS
CSS
 
XPath
XPathXPath
XPath
 
XSLT Overview
XSLT OverviewXSLT Overview
XSLT Overview
 
Views
ViewsViews
Views
 
CIS282 Midterm review
CIS282 Midterm reviewCIS282 Midterm review
CIS282 Midterm review
 
CIS 145 test 1 review
CIS 145 test 1 reviewCIS 145 test 1 review
CIS 145 test 1 review
 
XML schemas
XML schemasXML schemas
XML schemas
 
Document type definitions part 2
Document type definitions part 2Document type definitions part 2
Document type definitions part 2
 
Document type definitions part 1
Document type definitions part 1Document type definitions part 1
Document type definitions part 1
 
DOM specifics
DOM specificsDOM specifics
DOM specifics
 
SQL overview and software
SQL overview and softwareSQL overview and software
SQL overview and software
 
Cis166 final review c#
Cis166 final review c#Cis166 final review c#
Cis166 final review c#
 
Triggers
TriggersTriggers
Triggers
 
SQL Server Views
SQL Server ViewsSQL Server Views
SQL Server Views
 
Indexes
IndexesIndexes
Indexes
 
CIS145 Test 1 Review
CIS145 Test 1 ReviewCIS145 Test 1 Review
CIS145 Test 1 Review
 

Kürzlich hochgeladen

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 

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).