1 / 7

Computer Memory Programs Objects and object properties Instructions 1. Input

Program Statements …. …. Data Values …. …. Computer Memory Programs Objects and object properties Instructions 1. Input 2. assign values to memory 3. Calculate 4. compare and select 5. repeat a section of code 6. output

alika
Download Presentation

Computer Memory Programs Objects and object properties Instructions 1. Input

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Program Statements …. ….. Data Values …. ….. • Computer Memory • Programs • Objects and object properties • Instructions • 1. Input • 2. assign values to memory • 3. Calculate • 4. compare and select • 5. repeat a section of code • 6. output • Data – Values of Variables (and constants) • All these must be stored as a particular type of data

  2. Types of Variables currency string (text) integer single (Single precision floating point) (decimal number) double (double precision floating point) (bigger decimal number) boolean (true or false) etc. (see page 62) Declaring Variables: Objects on the form don’t have to be declared (They are already defined!) All Variables (other than Objects) will need to be declared: Dim Taxes as currency Dim CustomerID as integer, CustName as string Always use “option explicit” statement in “general code” section.

  3. Variable Types and Variable Declaration Variable Types Single, double, currency, integer, long, date, boolean, string Declaration statements (Dim) Option Explicit and setting the “require variable declaration” property in tools/options Code Windows and the General Code Window The “Scope” of variable declaration Suggestion: define all variables in the General Code Window Constants and declaring constants (Const) Example: Declare a variable in the code for command button click, then use that variable in code for a different command button click.

  4. Assignment statements Variable = Expression NetPay = RegularPay + OverTimePay Answer = 6 + 2 / 2 ^ 2 + 1 Expressions (arithmetic, logical) Order of operations [(), ^, -, *, /, \, Mod, +, -] Parentheses Functions – Val(), Str(), Format(variable, “currency”), CCur() IsNumeric()

  5. Code Windows The Object List General Form objects on the form (labels, text boxes, etc.) The Event List Click Double Click Load (for the Form) Key Press Got Focus

  6. Counters In the Initialization Code (Perhaps in the Form Load Event)(executed once): NumberOfEmployeesProcessed = 0 - In the Loop Code (executed repeatedly): - - GrossPay = RegularPay + OverTimePay - NumberOfEmployeesProcessed = NumberOfEmployeesProcessed + 1

  7. Counters and Sums In the Initialization Code (Perhaps in the Form Load Event)(executed once): NumberOfEmployeesProcessed = 0 TotalPayroll = 0 - In the Loop Code (executed repeatedly): - - GrossPay = RegularPay + OverTimePay - NumberOfEmployeesProcessed = NumberOfEmployeesProcessed + 1 TotalPayroll = TotalPayroll + GrossPay

More Related