Download - Midterm Winter 10
![Page 1: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/html5/thumbnails/1.jpg)
Midterm ReviewMidterm ReviewCIS-166
![Page 2: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/html5/thumbnails/5.jpg)
Scoping variablesScoping variablesWithin a blockWithin a procedureForm levelApplication level
![Page 6: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/html5/thumbnails/7.jpg)
Converting ValuesConverting ValuesConvert classData type – Parse/TryParseCTypeRole of Option Strict
![Page 8: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/html5/thumbnails/8.jpg)
OperatorsOperatorsMathematical
◦Precedence matters!◦^ ; - ; *, / ; \ ; Mod ; +, -
Relational◦< ; <= ; = ; >= ; >
Logical◦Precedence matters!◦Not; And ; Or
![Page 9: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/html5/thumbnails/12.jpg)
Event ProceduresEvent ProceduresConnect an action with
instructions using HandlesRoles of sender and event
◦What object◦Which event
![Page 13: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/html5/thumbnails/21.jpg)
PrintingPrintingPrintDocument v.
PrintPreviewDialogUsing Graphics
◦Role of ‘e’ (event argument)◦Managing print area
![Page 22: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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: Midterm Winter 10](https://reader035.vdocument.in/reader035/viewer/2022070316/555ec40ad8b42af67f8b4b81/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