Chapters 04 and 05 Combined

Chapters 04 and 05 Combined - Chapter 4: Writing Programs...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style Innovation Chapter 4: Writing Programs More Controls and New Logic MIS 304 – Introduction to Problem Solving and Programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MIS 304 Mantra First, solve the problem. Then, write the code. ~ John Johnson
Background image of page 2
You will learn how to… Determine the proper scope for a variable, declare variables as needed and use them appropriately Create and use counter and accumulators Create and use date and time variables Create and use Boolean variables Describe methods, create and use them to solve a programming
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
You will learn how to… Use the Load event at the start of a program Create, code and use the NumericUpDown and RichTextBox controls Use the MessageBox and InputBox controls Use methods to control and manipulate strings
Background image of page 4
Variable Scope Scope - the visibility of a variable in a program; where a variable can be used in a program So far, all variables have been created, used and discarded all within a click event The variables we’ve used have a local scope, so they are known as local variables
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Variable Scope Controlled by how and where a variable is declared Applies to variables and constants Local variable - a variable that is declared in a procedure; it is only visible in that procedure and can only be used there Module-level variable - a variable that is declared in a procedure; it is only visible in that procedure and
Background image of page 6
Module Level Variables Created in memory when form is loaded Stay in memory until the form is closed Can be used in any procedure on the form Created in the Declarations section of the code (aka “at the top”)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Declaration Area Module-level Variable Declaration
Background image of page 8
Counters and Accumulators Counters - a variable that increments (or decrements) by a set amount Accumulators - a variable used to keep a running total Declare counters and accumulators at the module level Used by many types of programs
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Counters Usually add 1 to a total Counters can increment (or decrement) by any value mshoCount = mShoCount + 1 OR mshoCount +=1
Background image of page 10
Accumulators Keep a running total Add two values on right and store in left mdecTotalSales = mdecTotalSales + decCurrentSale OR mdecTotalSales += decCurrentSale
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Counters and Accumulators Hands-on Counters and Accumulator s Demo
Background image of page 12
Methods Method - a procedure contained in a class; it performs an operation on data stored in the class Simplify a processes by reducing complicated calculations to a set of inputs Examples: DateDiff MessageBox.Show Recognized by IntelliSense
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Arguments Each method has its own list of arguments Arguments are inside parentheses and separated by commas var stores the answer Math.Method is the method arg1, arg2 is the argument list var = Math.Method(arg1,arg2…)
Background image of page 14
Square Root (SqRt) Method Finds the square root of a number var stores the answer Math.SqRt calls the square root method num is the number you need the square root of var = Math.SqRt(num)
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/29/2010 for the course MIS 304 taught by Professor Mote during the Fall '08 term at University of Texas.

Page1 / 86

Chapters 04 and 05 Combined - Chapter 4: Writing Programs...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online