cis-166 midterm
DESCRIPTION
review materials for cis-166 first testTRANSCRIPT
![Page 1: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/1.jpg)
Midterm ReviewMidterm ReviewCIS-166
![Page 2: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/2.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/3.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/4.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/5.jpg)
Scoping variablesScoping variablesWithin a blockWithin a procedureForm levelApplication level
![Page 6: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/6.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/7.jpg)
Converting ValuesConverting ValuesConvert classData type – Parse/TryParseCTypeRole of Option Strict
![Page 8: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/8.jpg)
OperatorsOperatorsMathematical
◦Precedence matters!◦^ ; - ; *, / ; \ ; Mod ; +, -
Relational◦< ; <= ; = ; >= ; >
Logical◦Precedence matters!◦Not; And ; Or
![Page 9: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/9.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/10.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/11.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/12.jpg)
Event ProceduresEvent ProceduresConnect an action with
instructions using HandlesRoles of sender and event
◦What object◦Which event
![Page 13: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/13.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/14.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/15.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/16.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/17.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/18.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/19.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/20.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/21.jpg)
PrintingPrintingPrintDocument v.
PrintPreviewDialogUsing Graphics
◦Role of ‘e’ (event argument)◦Managing print area
![Page 22: CIS-166 Midterm](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/22.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/23.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/24.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/25.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/26.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022061214/5499a53bb47959a66e8b459e/html5/thumbnails/27.jpg)
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