Using Variables, Constants, and Functions in Calculations - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Using Variables, Constants, and Functions in Calculations

Description:

String stores up to 2 billion alphanumeric characters letters, digits, and special ... Module (form) level constant defined in General Declarations section ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 21
Provided by: patimi
Category:

less

Transcript and Presenter's Notes

Title: Using Variables, Constants, and Functions in Calculations


1
Using Variables, Constants, and Functions in
Calculations
  • Chapter 2

2
Text Data Types
  • String stores up to 2 billion alphanumeric
    characters letters, digits, and special
    characters.
  • Byte stores 1 ASCII character.
  • Char stores 1 unicode character includes 65,000
    characters consisting of many languages.

3
Visual Basic .NET Data Types
4
Visual Basic .NET Data Types
5
Visual Basic .NET Data Types
6
Visual Basic .NET Data Types
7
Declaring Variables
  • You must declare or create a variable before you
    can use it.
  • Accessibility VariableName As Type Initial
    Value
  • Accessibility defines what procedures have access
    to the value stored in the variable.
  • Dim or Private
  • Initial Value is optional.

8
Default Values
  • Numeric 0
  • Boolean False (-1)
  • Date 1200 AM January 1, 0001
  • Object null
  • String - null

9
Variable Declaration
  • Explicit means you must use the Dim statement
    before you can use the variable.
  • Implicit means you can use the variable without a
    Dim statement. It will default to the Object data
    type.
  • You must use Option Explicit Off statement for
    implicit declaration.
  • Explicit variable declaration is one method of
    minimizing errors in your application.

10
Local Variable
  • Accessibility specifies which program statements
    will have access to the value stored in the
    variable.
  • Accessibility is also called variable scope.
  • A variable is a local variable and has procedure
    scope if it is declared within a procedure.
  • The Dim statement declares a local variable.

11
Module Level Variable
  • A module (or form) level variable is accessible
    to any procedure within a form.
  • A variable is a module level variable and has
    module scope if it is declared in the Form
    Declarations section.
  • The Private statement declares a module level
    variable.

12
Declaring Constants
  • Local Constant defined in procedure
  • Const conName As datatype expression
  • Module (form) level constant defined in General
    Declarations section
  • Private Const conName As datatype expression

13
Using ComboBox values
  • Dim intTerm as Integer
  • intTerm Val(cboTerm.Text)

14
Implicit (Predefined) Functions
  • A function is a procedure that returns a value.
  • Arguments are values supplied to the function.
  • Functions are used to simplify calculations.
  • Variable Val(argument)
  • Val
  • Format
  • InputBox
  • MsgBox
  • IPmt
  • Pmt
  • Ppmt

15
InputBox Function
  • Variable InputBox(Prompt, Title, Default
    Response)

16
Arithmetic Operators
  • Exponentiation
  • Multiplication
  • / Division with floating point result
  • \ Division with an integer result
  • MOD Result is the remainder of division
  • Addition
  • - Subtraction

17
Format Function
  • Format (expression, style)
  • Style is either a
  • pre-defined format ie. currency
  • or
  • User defined format ie. ,.00

18
Pre-defined Formats
19
Pre-defined Formats
20
User-defined Format Characters
Write a Comment
User Comments (0)
About PowerShow.com