cis-166 midterm

27
Midterm Review Midterm Review CIS-166

Upload: randy-riness-south-puget-sound-community-college

Post on 24-Dec-2014

625 views

Category:

Technology


0 download

DESCRIPTION

review materials for cis-166 first test

TRANSCRIPT

Page 1: CIS-166 Midterm

Midterm ReviewMidterm ReviewCIS-166

Page 2: CIS-166 Midterm

ObjectsObjectsClasses provide a templateProperties define the

characteristics and behaviors of an object

Methods are procedures that come with an object – actions it already knows how to do

Page 3: CIS-166 Midterm

Variables & ConstantsVariables & ConstantsMemory location for storing data

◦Variable value can change◦Constant value doesn’t change

Different types of data◦Tailor data type to ensure get good

data and maximize use of memory Default data type is object

Page 4: CIS-166 Midterm

Variable UseVariable UseOption Explicit makes sure that

variables are declared (defined)Create using Dim or PublicVariables initialized when created

(setting beginning value)

Page 5: CIS-166 Midterm

Scoping variablesScoping variablesWithin a blockWithin a procedureForm levelApplication level

Page 6: CIS-166 Midterm

EnumeratorsEnumeratorsEnumerators are a way to

manage related constants◦Messagebox buttons◦Type of transaction

Value of a member must be an integer◦Value defaults to 0 for 1st, 1 + prior

value for each additional member

Page 7: CIS-166 Midterm

Converting ValuesConverting ValuesConvert classData type – Parse/TryParseCTypeRole of Option Strict

Page 8: CIS-166 Midterm

OperatorsOperatorsMathematical

◦Precedence matters!◦^ ; - ; *, / ; \ ; Mod ; +, -

Relational◦< ; <= ; = ; >= ; >

Logical◦Precedence matters!◦Not; And ; Or

Page 9: CIS-166 Midterm

If … ThenIf … ThenIf something is true, execute

following commandsCan test for more than one

condition◦Else◦ElseIf

Nested If … Then‘Is’ functions help testing

Page 10: CIS-166 Midterm

Case StructureCase StructureBest alternative for testing a

single variable or expression for multiple values

Any decisions coded with nested If statements can also be coded using Case structure

Case Structure is typically simpler, cleaner, more efficient than an If … Then

Page 11: CIS-166 Midterm

ProceduresProceduresSubroutine: procedures that

don’t return somethingFunction: procedures that send

back some dataProperties: procedures that

store, return, or both; accept a single argument

Arguments are means to provide data to a procedure

Page 12: CIS-166 Midterm

Event ProceduresEvent ProceduresConnect an action with

instructions using HandlesRoles of sender and event

◦What object◦Which event

Page 13: CIS-166 Midterm

Sharing an Event Sharing an Event ProcedureProcedureIf the code for multiple controls is similar,

rather than writing separate code for each, the controls can share an event procedure

Use the Handles Clause at the top of the event procedure to enable the code in a single event to be used for multiple controls

Can evaluate the sender to determine the object which triggered the event

Different events have different data types (i.e. form closing is different than click)

Page 14: CIS-166 Midterm

Types of List ControlsTypes of List ControlsListBox: Simple List Box with or

without scroll barsComboBox

◦List may allow for user to add new items

◦List may "drop down" to display items in list

◦Combines characteristics of a TextBox with a ListBox

Page 15: CIS-166 Midterm

Items CollectionItems Collection

List of items in a ListBox or ComboBox is a collection

Collections are objects that have properties and methods that allow you to◦Add items◦Remove items◦Refer to individual items◦Count items

Page 16: CIS-166 Midterm

Index PropertyIndex Property

Zero based value used to reference individual items in the collection

Position of an item in the list◦ 1st item Index = 0 (1-1=0)◦ 2nd item Index = 1 (2-1=1)◦ 3rd item Index = 2 (3-1=2)

Page 17: CIS-166 Midterm

LoopsLoopsRepeating a series of instructionsEach repetition is called an

iterationTypes of Loops

◦Do: Use when the number of iterations is unknown

◦For Next: Use when the number of iterations known

Page 18: CIS-166 Midterm

Do LoopsDo LoopsEnds based on a condition you

specify, either◦Loop While a condition is True◦Loop Until a condition becomes True

Condition can be located at◦Top of Loop, Pretest◦Bottom of Loop, Posttest

Page 19: CIS-166 Midterm

For Next LoopsFor Next Loops

Use when you know the number of iterations

Uses a numeric counter variableCounter (Loop Index) is

incremented at the bottom of the loop on each iteration

Step value specifies the amount to change the Counter◦Step can be a negative number

Page 20: CIS-166 Midterm

CType FunctionCType FunctionConverts object from one type to

anotherCType (ValueToConvert,

NewType)Example

Dim radSelected as RadioButtonradSelected = CType(sender, RadioButton)Select Case radSelected . Name

Case "radBlue". . .

Page 21: CIS-166 Midterm

PrintingPrintingPrintDocument v.

PrintPreviewDialogUsing Graphics

◦Role of ‘e’ (event argument)◦Managing print area

Page 22: CIS-166 Midterm

ArraysArraysList or series of values all

referenced by the same nameUse an array to keep a series of

variables for later processing such as ◦Reordering◦Calculating◦Printing

Page 23: CIS-166 Midterm

Array TermsArray TermsElement

◦Individual item in the arrayIndex (or subscript)

◦Zero based number used to reference the specific elements in the array

◦Must be an integerBoundaries

◦Lower Subscript, 0 by default◦Upper Subscript

Page 24: CIS-166 Midterm

For Next LoopFor Next LoopReads in order of position in

array

Dim intCounter, intEnd as IntegerintEnd = strNames.GetUpperBound(0)For intCounter = 0 to intEnd

Console.Writeline(strNames(intCounter))Next

Page 25: CIS-166 Midterm

For Each LoopFor Each LoopReads based on position of

member in memory

Dim strItem as StringFor Each strItem in strNames

Console.Writeline(strItem)Next

Page 26: CIS-166 Midterm

ReDimReDimUse the ReDim keyword to

change the length of the array◦Can increase or decrease the

number of elements◦Can keep existing values of elements

using Preserve

ReDim Preserve strNames(19)

Page 27: CIS-166 Midterm

StructureStructureAllows multiple values and

procedures to be described as a data type

Similar to defining a table in a database

Does not need to be instantiated as a class does