Midterm Winter 10

461 views
435 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
461
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • CIS-166 Spring 2009 Midterm Review
  • CIS-166 Spring 2009 Midterm Review
  • Midterm Winter 10

    1. 1. Midterm Review CIS-166
    2. 2. Objects <ul><li>Classes provide a template </li></ul><ul><li>Properties define the characteristics and behaviors of an object </li></ul><ul><li>Methods are procedures that come with an object – actions it already knows how to do </li></ul>
    3. 3. Variables & Constants <ul><li>Memory location for storing data </li></ul><ul><ul><li>Variable value can change </li></ul></ul><ul><ul><li>Constant value doesn’t change </li></ul></ul><ul><li>Different types of data </li></ul><ul><ul><li>Tailor data type to ensure get good data and maximize use of memory </li></ul></ul><ul><ul><ul><li>Default data type is object </li></ul></ul></ul>
    4. 4. Variable Use <ul><li>Option Explicit makes sure that variables are declared (defined) </li></ul><ul><li>Create using Dim or Public </li></ul><ul><li>Variables initialized when created (setting beginning value) </li></ul>
    5. 5. Scoping variables <ul><li>Within a block </li></ul><ul><li>Within a procedure </li></ul><ul><li>Form level </li></ul><ul><li>Application level </li></ul>
    6. 6. Enumerators <ul><li>Enumerators are a way to manage related constants </li></ul><ul><ul><li>Messagebox buttons </li></ul></ul><ul><ul><li>Type of transaction </li></ul></ul><ul><li>Value of a member must be an integer </li></ul><ul><ul><li>Value defaults to 0 for 1 st , 1 + prior value for each additional member </li></ul></ul>
    7. 7. Converting Values <ul><li>Convert class </li></ul><ul><li>Data type – Parse/TryParse </li></ul><ul><li>CType </li></ul><ul><li>Role of Option Strict </li></ul>
    8. 8. Operators <ul><li>Mathematical </li></ul><ul><ul><li>Precedence matters! </li></ul></ul><ul><ul><li>^ ; - ; *, / ; ; Mod ; +, - </li></ul></ul><ul><li>Relational </li></ul><ul><ul><li>< ; <= ; = ; >= ; > </li></ul></ul><ul><li>Logical </li></ul><ul><ul><li>Precedence matters! </li></ul></ul><ul><ul><li>Not; And ; Or </li></ul></ul>
    9. 9. If … Then <ul><li>If something is true, execute following commands </li></ul><ul><li>Can test for more than one condition </li></ul><ul><ul><li>Else </li></ul></ul><ul><ul><li>ElseIf </li></ul></ul><ul><li>Nested If … Then </li></ul><ul><li>‘ Is’ functions help testing </li></ul>
    10. 10. Case Structure <ul><li>Best alternative for testing a single variable or expression for multiple values </li></ul><ul><li>Any decisions coded with nested If statements can also be coded using Case structure </li></ul><ul><li>Case Structure is typically simpler, cleaner, more efficient than an If … Then </li></ul>
    11. 11. Procedures <ul><li>Subroutine: procedures that don’t return something </li></ul><ul><li>Function: procedures that send back some data </li></ul><ul><li>Properties: procedures that store, return, or both; accept a single argument </li></ul><ul><li>Arguments are means to provide data to a procedure </li></ul>
    12. 12. Event Procedures <ul><li>Connect an action with instructions using Handles </li></ul><ul><li>Roles of sender and event </li></ul><ul><ul><li>What object </li></ul></ul><ul><ul><li>Which event </li></ul></ul>
    13. 13. Sharing an Event Procedure <ul><li>If the code for multiple controls is similar, rather than writing separate code for each, the controls can share an event procedure </li></ul><ul><li>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 </li></ul><ul><li>Can evaluate the sender to determine the object which triggered the event </li></ul><ul><li>Different events have different data types (i.e. form closing is different than click) </li></ul>
    14. 14. Types of List Controls <ul><li>ListBox: Simple List Box with or without scroll bars </li></ul><ul><li>ComboBox </li></ul><ul><ul><li>List may allow for user to add new items </li></ul></ul><ul><ul><li>List may &quot;drop down&quot; to display items in list </li></ul></ul><ul><ul><li>Combines characteristics of a TextBox with a ListBox </li></ul></ul>
    15. 15. Items Collection <ul><li>List of items in a ListBox or ComboBox is a collection </li></ul><ul><li>Collections are objects that have properties and methods that allow you to </li></ul><ul><ul><li>Add items </li></ul></ul><ul><ul><li>Remove items </li></ul></ul><ul><ul><li>Refer to individual items </li></ul></ul><ul><ul><li>Count items </li></ul></ul>
    16. 16. Index Property <ul><li>Zero based value used to reference individual items in the collection </li></ul><ul><li>Position of an item in the list </li></ul><ul><ul><li>1st item Index = 0 (1-1=0) </li></ul></ul><ul><ul><li>2nd item Index = 1 (2-1=1) </li></ul></ul><ul><ul><li>3rd item Index = 2 (3-1=2) </li></ul></ul>
    17. 17. Loops <ul><li>Repeating a series of instructions </li></ul><ul><li>Each repetition is called an iteration </li></ul><ul><li>Types of Loops </li></ul><ul><ul><li>Do: Use when the number of iterations is unknown </li></ul></ul><ul><ul><li>For Next: Use when the number of iterations known </li></ul></ul>
    18. 18. Do Loops <ul><li>Ends based on a condition you specify, either </li></ul><ul><ul><li>Loop While a condition is True </li></ul></ul><ul><ul><li>Loop Until a condition becomes True </li></ul></ul><ul><li>Condition can be located at </li></ul><ul><ul><li>Top of Loop, Pretest </li></ul></ul><ul><ul><li>Bottom of Loop, Posttest </li></ul></ul>
    19. 19. For Next Loops <ul><li>Use when you know the number of iterations </li></ul><ul><li>Uses a numeric counter variable </li></ul><ul><li>Counter (Loop Index) is incremented at the bottom of the loop on each iteration </li></ul><ul><li>Step value specifies the amount to change the Counter </li></ul><ul><ul><li>Step can be a negative number </li></ul></ul>
    20. 20. CType Function <ul><li>Converts object from one type to another </li></ul><ul><li>CType ( ValueToConvert, NewType ) </li></ul><ul><li>Example </li></ul><ul><ul><li>Dim radSelected as RadioButton </li></ul></ul><ul><ul><li>radSelected = CType(sender, RadioButton) </li></ul></ul><ul><ul><li>Select Case radSelected . Name </li></ul></ul><ul><ul><li>Case &quot;radBlue&quot; </li></ul></ul><ul><ul><li>. . . </li></ul></ul>
    21. 21. Printing <ul><li>PrintDocument v. PrintPreviewDialog </li></ul><ul><li>Using Graphics </li></ul><ul><ul><li>Role of ‘e’ (event argument) </li></ul></ul><ul><ul><li>Managing print area </li></ul></ul>
    22. 22. Arrays <ul><li>List or series of values all referenced by the same name </li></ul><ul><li>Use an array to keep a series of variables for later processing such as </li></ul><ul><ul><li>Reordering </li></ul></ul><ul><ul><li>Calculating </li></ul></ul><ul><ul><li>Printing </li></ul></ul>
    23. 23. Array Terms <ul><li>Element </li></ul><ul><ul><li>Individual item in the array </li></ul></ul><ul><li>Index (or subscript) </li></ul><ul><ul><li>Zero based number used to reference the specific elements in the array </li></ul></ul><ul><ul><li>Must be an integer </li></ul></ul><ul><li>Boundaries </li></ul><ul><ul><li>Lower Subscript, 0 by default </li></ul></ul><ul><ul><li>Upper Subscript </li></ul></ul>
    24. 24. For Next Loop <ul><li>Reads in order of position in array </li></ul><ul><li>Dim intCounter, intEnd as Integer </li></ul><ul><li>intEnd = strNames.GetUpperBound(0) </li></ul><ul><li>For intCounter = 0 to intEnd </li></ul><ul><ul><li>Console.Writeline(strNames(intCounter)) </li></ul></ul><ul><li>Next </li></ul>
    25. 25. For Each Loop <ul><li>Reads based on position of member in memory </li></ul><ul><li>Dim strItem as String </li></ul><ul><li>For Each strItem in strNames </li></ul><ul><ul><li>Console.Writeline(strItem) </li></ul></ul><ul><li>Next </li></ul>
    26. 26. ReDim <ul><li>Use the ReDim keyword to change the length of the array </li></ul><ul><ul><li>Can increase or decrease the number of elements </li></ul></ul><ul><ul><li>Can keep existing values of elements using Preserve </li></ul></ul><ul><li>ReDim Preserve strNames(19) </li></ul>
    27. 27. Structure <ul><li>Allows multiple values and procedures to be described as a data type </li></ul><ul><li>Similar to defining a table in a database </li></ul><ul><li>Does not need to be instantiated as a class does </li></ul>

    ×