0
CIS-160Final Review
Final Exam100 pointsOpen book, open notesTrue/false, multiple choice, fill-in, short answer
Variables and ConstantsVariable: Memory locations that hold data that can bechanged during project execution  Example: cus...
Using Variables and ConstantsIn Visual Basic when you declare a Variable or NamedConstant  An area of memory is reserved  ...
Declaration StatementsAssign name and data typeNot executable statements unless a value is assignedon same line
Naming Variables & ConstantsMust follow Visual Basic Naming Rules  Cannot use reserved words or keywords that Basic has  a...
Scope and Lifetime of Variables Visibility of a variable is its scope   Where is that identifier valid? Scope may be   Nam...
Static VariablesUse static to declare local and block level variablesthat need to retain their valueVariable will not be i...
Converting Strings to Numeric Values  Use Parse methods to convert a string to its numeric  value before it’s used in a ca...
Try/Catch BlocksEnclose statements that might cause a run-time errorwithin Try/Catch blockIf an exception occurs while sta...
Using Overloaded MethodsThis OOP feature allows the Messagebox Showmethod to act differently for different argumentsEach a...
If StatementsUsed to make decisionsIf true, only the Then clause is executed; if false, onlyElse clause is executed (if th...
ConditionsTest in an If statement is typically based on aconditionSix relational operators are used for comparison ofnumbe...
Combining Logical OperatorsCompound conditions can combine multiple logicalconditions  And describes conditions where both...
Input ValidationCheck to see if valid values were entered or availableCan check for a range of values (often called“reason...
Select CaseUse Select Case to test one value for differentmatches (“cases”)Usually simpler and clearer than nested IfNo li...
Sharing an Event ProcedureAdd object/event combinations to the Handles clauseat the top of an event procedureAllows the pr...
Calling Event ProceduresCalling an event procedure allows reuse of code[Call] ProcedureName (arguments)  Keyword Call is o...
BreakpointsBreakpoints allow you to follow the execution of yourcode while program is running  Can hover the cursor over a...
Writing ProceduresA general procedure is reusable code which can becalled from multiple proceduresUseful for breaking down...
Passing Arguments to Procedures  If a procedure includes an argument, any call to the  procedure must supply a value for t...
Modal versus Modeless FormsShow method displays a form as modeless - meansthat both forms are open and the user can move f...
ListBoxes and ComboBoxesProvide the user with a list of choices to select fromVarious styles of display, choose based on  ...
The Items CollectionList of items in a ListBox or ComboBox is a collection  Collection is group of like objects  Items ref...
SelectedIndexIndex number of currently selected item is stored inthe SelectedIndex property  Property is zero-based  If no...
Do LoopsA loop repeats a series of instructionsAn iteration is a single execution of the statement(s) in theloopUsed when ...
Pretest vs. PosttestPretest: test before enter loop  loop may never be executed since test executes  BEFORE entering loop ...
For/Next LoopsUsed to repeat statements in a loop a specific number oftimesUses a numeric counter variable called Counter ...
For/Each LoopsUsed to repeat statements for each member of agroupA reference variable is used to “point” to each itemMust ...
Exiting LoopsIn some situations you may need to exit the loop earlyUse the Exit For or Exit Do statement inside the loopTy...
ArraysList or series of variables all referenced by the samename  Similar to list of values for list boxes and combo boxes...
Array TermsElement: Individual item in the arraySubscript (or index): Zero-based identifier used toreference the specific ...
SubscriptsSubscripts may be constants, variables, or numericexpressionsSubscripts must be integersSubscripts begin at zero...
Upcoming SlideShare
Loading in...5
×

CIS160 final review

269

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
269
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

Transcript of "CIS160 final review"

  1. 1. CIS-160Final Review
  2. 2. Final Exam100 pointsOpen book, open notesTrue/false, multiple choice, fill-in, short answer
  3. 3. Variables and ConstantsVariable: Memory locations that hold data that can bechanged during project execution Example: customer’s nameNamed Constant: Memory locations that hold datathat cannot be changed during project execution Example: sales tax rate
  4. 4. Using Variables and ConstantsIn Visual Basic when you declare a Variable or NamedConstant An area of memory is reserved A name is assigned called an Identifier
  5. 5. Declaration StatementsAssign name and data typeNot executable statements unless a value is assignedon same line
  6. 6. Naming Variables & ConstantsMust 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 periodsShould follow Naming Conventions Names should be meaningful Include class (data type) of variable in nameUse mixed case for variables and uppercase forconstants
  7. 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. 8. Static VariablesUse static to declare local and block level variablesthat need to retain their valueVariable will not be initialized next time procedureruns, and will have last value assignedIf the variable is used in multiple procedures, declareit at the module level with private Pass data as arguments if one procedure calls the other
  9. 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. 10. Try/Catch BlocksEnclose statements that might cause a run-time errorwithin Try/Catch blockIf an exception occurs while statements in the Tryblock are executing, code execution is moved to theCatch BlockIf a Finally statement is included, the code in thatsection executes last, whether or not an exceptionoccurred
  11. 11. Using Overloaded MethodsThis OOP feature allows the Messagebox Showmethod to act differently for different argumentsEach argument list is called a signature: the Showmethod has multiple signaturesSupplied arguments must exactly match one of thesignatures provided by the method
  12. 12. If StatementsUsed to make decisionsIf true, only the Then clause is executed; if false, onlyElse clause is executed (if there is an Else)Block If…Then…Else must always conclude with EndIfThen must be on same line as If or ElseIfEnd If and Else appear alone on a line
  13. 13. ConditionsTest in an If statement is typically based on aconditionSix relational operators are used for comparison ofnumbers, dates, and text Equal sign is used to test for equalityStrings are compared using ANSI value of eachcharacter CIS is less than CNA MATH is less than MATH&
  14. 14. Combining Logical OperatorsCompound conditions can combine multiple logicalconditions And describes conditions where both tests are true Or describes conditions where either or both tests are trueWhen both And and Or are evaluated And isevaluated before the Or Use parenthesis to change the order of evaluation
  15. 15. Input ValidationCheck to see if valid values were entered or availableCan 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. 16. Select CaseUse Select Case to test one value for differentmatches (“cases”)Usually simpler and clearer than nested IfNo limit to number of statements that follow a CasestatementWhen using a relational operator must use the wordIsUse the word “To” to indicate a range with twoendpoints
  17. 17. Sharing an Event ProcedureAdd object/event combinations to the Handles clauseat the top of an event procedureAllows the procedure to be associated with differentevents or other controlsSender argument identifies which object had theevent happenCast (convert) sender to a specific object type usingthe CType function
  18. 18. Calling Event ProceduresCalling an event procedure allows reuse of code[Call] ProcedureName (arguments) Keyword Call is optional and rarely usedExamplesCall clearButton_Click (sender, e)--OR--clearButton_Click (sender, e)
  19. 19. BreakpointsBreakpoints allow you to follow the execution of yourcode 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 proceduresCan use Console.Writeline to output values to trackcode executionVariables and property values can be seen in differentwindows (autos, locals) while code is executing
  20. 20. Writing ProceduresA general procedure is reusable code which can becalled from multiple proceduresUseful for breaking down large sections of code intosmaller unitsTwo types: Sub Procedure performs actions Function Procedure performs actions AND returns a value (the return value)
  21. 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. 22. Modal versus Modeless FormsShow method displays a form as modeless - meansthat both forms are open and the user can move fromone form to the otherShowDialog method displays a new form as modal -the user must close the form in order to return to theoriginal form No other program code in the original form can execute until the user responds to and hides or closes the modal form
  23. 23. ListBoxes and ComboBoxesProvide the user with a list of choices to select fromVarious styles of display, choose based on Space available Need to select from an existing list Need to add to a listListboxes and comboboxes share most of the sameproperties and operate in a similar way Combo box control has a DropDown Style property Combo box allows text entry
  24. 24. The Items CollectionList 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 andmethods that allow Adding items Removing items Referring to an individual element/member Counting items
  25. 25. SelectedIndexIndex number of currently selected item is stored inthe 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. 26. Do LoopsA loop repeats a series of instructionsAn iteration is a single execution of the statement(s) in theloopUsed when the exact number of iterations is unknownA Do/Loop terminates based on condition changeExecution of the loop continues while a condition is True oruntil a condition is TrueThe condition can be placed at the top or the bottom ofthe loop
  27. 27. Pretest vs. PosttestPretest: test before enter loop loop may never be executed since test executes BEFORE entering loop Do While … Loop Do Until … LoopPosttest: test at end of loop loop will always be executed at least once Do … Loop While Do … Loop Until
  28. 28. For/Next LoopsUsed to repeat statements in a loop a specific number oftimesUses a numeric counter variable called Counter or LoopIndex Counter is incremented at the bottom of the loop on each iterationStart value sets initial value for counterEnd value sets final value for counterStep value can be included to specify the incrementingamount Step can be a negative number
  29. 29. For/Each LoopsUsed to repeat statements for each member of agroupA reference variable is used to “point” to each itemMust be the data type of each item in group
  30. 30. Exiting LoopsIn some situations you may need to exit the loop earlyUse the Exit For or Exit Do statement inside the loopTypically used in an If statement (some conditiondetermines whether to exit the loop or not)
  31. 31. ArraysList or series of variables all referenced by the samename 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 typeIndividual elements are treated the same as any otherindividual variable
  32. 32. Array TermsElement: Individual item in the arraySubscript (or index): Zero-based identifier used toreference the specific elements in the array Must be an integerSubscript Boundaries Lower Subscript, 0 by default Upper Subscript
  33. 33. SubscriptsSubscripts may be constants, variables, or numericexpressionsSubscripts must be integersSubscripts begin at zero (0)VB throws exceptions for subscripts that are out ofrange (upper and lower bounds).
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×