This article is about data types used in visual basic.Data type is referred to as type of data which show the memory space taken by data.
As we study data types in other high level languages such as c and c++,in this language also same data type as well as some extra data types.
Memory location that hold data that can be changed during project execution are called variables.
We can say that a name assign to memory for store data is called variable.
Declaration of variable is of two types:-
Explicit:-As the type clause in the Dim statement allows to define the data type or object type of the variable.This is called explicit declaration.
Implicit:- When in vb encounters a new variable ,it assigns the default variable type &value.This is called implicit declaration..This is called implicit declaration.This is useful for user to control over variables.
Constant:- Location that hold data that can not change during execution are called constants.
Const keyword is used for declaration.
Ex. Const a as interger=10
If data type is not given then it is of type variant.
const is always declare globally.It can't declare in procedure.
Variant:- Variant data type means that when we not declare data type then by default it is of type variant .it is called variant because variable and constant change their appearance as needed for each situation.
But negetive point behind this is that it is less efficient than the other data types.It requires more memory space and operate less quickly than other.
Note:-Always try specify the data type.
There are another data types with their use.
True and false.
It is used for a single ASCII character.
It is used for decimal fractions such as dollar & cents.
It show 8 character date.
It is for double precission floating point numbers with 14 digits of accuracy.
For whole number with range -32768 to 32767
7.Long:-Provide larger whole numbers.
Single precission floating point numbers with 6 digits of accuracy.
Convert from one type to another when needed.
Alphanumeric data,letters,digits and other characters.
Deciding which data type used when:-
The most common data types are string ,currency and integers.
1. When we require calculation we should use numeric(integer & currency)
2. No calculatio then should use string.
3. for decimal fraction in business application ,currency should use.
4. For scientific application single and double should use.
we will discuss some more other classification of data type in next article.
Thanks to being with us...........stay in touch.