IS 118 Introduction To Development Tools: VB Chapter 04
IS 118 Introduction To Development Tools: VB Chapter 04
Development Tools
VB Chapter 04
IS 118
Chapter 4
Data, Operations, and Built-In
Functions
Visual Basic. NET
Objectives
Differentiate
Objectives
Understand
statement
Recognize and use various arithmetic
expressions and functions
Understand the usefulness of strict type
checking
Recognize and use various string functions
Understand better how data and VB controls are
used together in a project
IS 118
Classification of Data
MsgBox(Your
Text
Text
Numeric
Data
IS 118
Declaring Constants
Some
Known
as system constants
Examples include True and False
Others
Known
as symbolic constants
Must be declared with Const statement
To
Name
IS 118
Declaring Variables
Declared
type
Can
Code
Syntax:
Defines
Default
IS 118
10
Helps
IS 118
11
Cannot
contain spaces
If it has same name as a reserved keyword, i.e.
Date, must be enclosed with brackets
Cannot contain embedded periods or data suffix
characters
IS 118
12
IS 118
13
Class-Level Variables
Code
IS 118
14
Procedure-Level Variables
Declared
inside a procedure
Scope:
15
Declaration Issues
Block-level
declaration:
Overlapping
declarations:
In
16
Access Modifiers
With
Public
Private
MyIDNum as Integer
Private
MyIDNum as Integer
IS 118
17
Objects
An
Think
called instantiation
IS 118
18
Declaring Objects
To use
type
19
Different
20
Often
Char
Often
Neither
21
Short
Integer
Long
IS 118
22
Different
IS 118
23
IS 118
24
Option
You
25
Assignment Statement
OvertimePay
IS 118
26
Numeric Operations
Code
IS 118
27
Operational Precedence
Order
of Preference
Power
Unary negation
Multiplication and division
Integer division
Mod
Addition and subtraction
To enforce
IS 118
28
An Application Example:
Computing Net Sales
Analyze
Determine
Declaring
controls needed
29
An Application Example:
Computing Net Sales
Computations
Decide
boxes
Create formulas for computation
Decide how to display result of computations
Format
IS 118
30
IS 118
31
IS 118
32
Functions
Math
Date/Time
33
Conversion Functions
Used
IS 118
34
String Data
Declared
combines 2 strings
Valid concatenation operators: & and +
If
IS 118
35
IS 118
36
An Application Example:
The Calculating Vending Machines
Analyze
Setting
IS 118
37
Application Example:
The Calculating Vending Machine
Determining
Must
Selected Items
If
Obtaining
Price
the Price
Must
38
Application Example:
The Calculating Vending Machine
Accumulating the total
When user selects an item, the cost must be added to
the accumulated total
Declaring variables
Give special consideration to scope and type
Checking out
Need a mechanism to allow user to indicate he/she has
finished ordering
Need a routine in case the user checks out without
buying anything
Reinitialize class-level variables after checking out
IS 118
39
IS 118
40
IS 118
41
Summary
IS 118
42
Summary
IS 118
43
Summary
VB
44