Key Terms – Programming
BTEC National for IT Practitioners Unit 6: Software Design & Development
Objectives
Variables
Declaring Variable
Declaring Variables
What Data Types are Supported?
Why are Data Types used?
Why are Data Types used?
Why are Data Types used?
So, what are the benefits?
So, what are the benefits?
Assignment 1 – For P4
507.00K
Category: programmingprogramming

Unit 6: Software Design & Development. Data Types in Programming

1. Key Terms – Programming

S
E
R
V
I
C
E
Y
O
R
T
Y
U
T
A
D
S
F
G
H
H
R
E
K
U
H
U
R
E
R
S
C
Q
H
I
W
J
L
A
Y
R
I
F
C
V
E
G
E
Q
N
I
N
T
F
E
G
W
B
R
F
N
W
E
O
D
R
G
R
G
G
F
T
D
T
E
V
P
L
E
H
F
H
O
E
Y
E
E
R
I
K
E
D
D
E
J
K
R
R
S
D
T
R
J
R
E
V
E
N
T
S
I
W
Y
G
D
M
S
L
P
E
I
M
T
H
S
G
F
T
E
N
K
O
P
R
S
C
L
I
C
K
T
M
F
K
L
O
S
T
I
O
X
M
D
U
I
G
J
F
W
Z
X
Y
P
S
N
S
J
T
V
Service
Oriented
Time
Driven
Events
Click
Trigger
Forms
Handlers

2. BTEC National for IT Practitioners Unit 6: Software Design & Development

BTEC National for IT Practitioners
Unit 6: Software Design &
Development
Data Types

3. Objectives

What are Variables?
The Data Types supported by VB
Understand why Data Types are used

4. Variables

When a program runs, any data it uses must be
stored in RAM
A variable is a name made up by a programmer
to identify the address in RAM where a piece of
data is stored
Every variable must be of a given data type (see
word document “Data Types”)

5. Declaring Variable

To declare a variable means to tell Visual Basic two
things about it


Its name
Its data type
Use the keywords Dim and As when you
declare a variable, for example



Dim Number As Integer
Dim Payment As Decimal
Dim DateOfPayment As Date

6. Declaring Variables

You can declare more than one variable of the same
type in the same line of code, for example

Dim FirstNumber, SecondNumber, ThirdNumber As Integer

7. What Data Types are Supported?

See “Data Types” document

8. Why are Data Types used?

Data Types are used to determine what type of information is
going to be stored in a variable (will it be a date, a number or
some text)
Data Types also determine how much space in memory (RAM) the
variable needs to store the information
Each Data Type has a maximum size (this is what has the impact
on memory)
Important to choose the correct Data Type for variables to ensure
that the most efficient amount of storage space needed is used

9. Why are Data Types used?

Data Types are also used to help validate what is being stored in
each variable (since VB will present you with an error message if
you put a different type of value in a variable with the wrong data
type)
For example, VB will not let you put text or numbers into a variable
with a Date data type
And VB will not let you put text into a field with a Number data type
The result will be that the program will “fall-over” displaying an error
message

10. Why are Data Types used?

Having different Data Types allows you to perform calculation on
the different values of variable (such as Adding values of
variables)
Having different Data Types also allows different formatting to be
applied to the field when you create reports or data entry screen
For example, a Date field in VB (just like in Access) can be
printed or displayed with the following different formats



11/09/2011
11 Sept 2011
11 September 2011

11. So, what are the benefits?

Accurate storage


This is vitally important for numeric values. If the data type is too small to
store a value, it becomes truncated (chopped) and accuracy is lost.
Using a data type of the right size prevents this happening
Efficiency of storage

This is important particularly in computer systems where free RAM or
processing power may be limited
Additional validation

Entering non-numeric data into a numeric data type can cause a
program to crash at runtime

12. So, what are the benefits?

Calculations


Data that you need to do calculations with must be placed in a numeric data
type such as integer or single
Placing non-numeric data into these variables, will result in the program
crashing
Formatting

By having data types you can take advantage of the formatting that can be
applied to each type and make the presentation of information stored in
variable appear more user friendly
Consistency

Data types give the programmer the ability to have variables that have a
consistent style throughout the program (with a consistent format and options)

13. Assignment 1 – For P4

Create a table in word to list some of the data types that are
available in Visual Basic, with their size, space taken up (in
RAM) and the short/brief description of the type of data that
should be stored in the data type (include some examples)
Under the table provide a description of the benefits gained
by having a variety of different data types available when
producing programs
English     Русский Rules