CIS160 final review
Upcoming SlideShare
Loading in...5
×
 
  • 360 views

 

Statistics

Views

Total Views
360
Views on SlideShare
325
Embed Views
35

Actions

Likes
0
Downloads
2
Comments
0

1 Embed 35

http://rriness.spscc.edu 35

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    CIS160 final review CIS160 final review Presentation Transcript

    • 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: customer’s nameNamed Constant: Memory locations that hold datathat cannot be changed during project execution Example: sales tax rate
    • 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
    • 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 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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&
    • 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
    • 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 ...
    • 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
    • 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
    • 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)
    • 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
    • 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)
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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)
    • 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
    • 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
    • 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).