1 / 20

Using Variables, Constants, and Functions in Calculations

Using Variables, Constants, and Functions in Calculations. Chapter 2. Text Data Types. String stores up to 2 billion alphanumeric characters – letters, digits, and special characters. Byte stores 1 ASCII character.

janet
Download Presentation

Using Variables, Constants, and Functions in Calculations

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. 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 – 12:00 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. 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 Implicit (Predefined) Functions

  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

More Related