Вы находитесь на странице: 1из 8

Visual Basic Data Types :

To specifying a data type in a declaration statement, you can force


the data type of some programming elements by using a type
character.
When you declare an elementary data type, it is not safe to assume
that its memory consumption is the same as its nominal storage
allocation. This is due to the following considerations:
Storage Assignment: The common language runtime can assign
storage based on the current characteristics of the platform on
which your application is executing. If memory is nearly full, it
might pack your declared elements as closely together as
possible. In other cases it might align their memory addresses to
natural hardware boundaries to optimize performance.
Platform Width: Storage assignment on a 64-bit platform is
different from assignment on a 32-bit platform.
*****
Data Types :
1- Boolean Data Type :
Holds values that can be only True or False. The keywords True
and False correspond to the two states of Boolean variables.

2- Byte data type :


Holds unsigned 8-bit (1-byte) integers that range in value from 0
through 255.

Char Data Type :


Holds unsigned 16-bit (2-byte) code points ranging in value from
0 through 65535. Each code point, or character code, represents a
single Unicode character.
Date Data Type :

Holds IEEE 64-bit (8-byte) values that represent dates ranging


from January 1 of the year 0001 through December 31 of the year
9999, and times from 12:00:00 AM (midnight) through
11:59:59.9999999 PM. Each increment represents 100
nanoseconds of elapsed time since the beginning of January 1 of
the year 1 in the Gregorian calendar. The maximum value
represents 100 nanoseconds before the beginning of January 1 of
the year 10000.

Decimal Data Type :

Holds signed 128-bit (16-byte) values representing 96-bit (12-


byte) integer numbers scaled by a variable power of 10. The
scaling factor specifies the number of digits to the right of the
decimal point; it ranges from 0 through 28. With a scale of 0 (no
decimal places), the largest possible value
is+/79,228,162,514,264,337,593,543,950,335(+/7.92281625142
64337593543950335E+28). With 28 decimal places, the largest
value is+/-7.9228162514264337593543950335, and the smallest
nonzero value is +/-0.0000000000000000000000000001 (+/-1E-
28).

Double Data Type :

Holds signed IEEE 64-bit (8-byte) double-precision floating-


point numbers that range in value from -
1.79769313486231570E+308 through -4.94065645841246544E-
324 for negative values and from 4.94065645841246544E-324
through 1.79769313486231570E+308 for positive values.
Double-precision numbers store an approximation of a real
number.
Integer data type :

Holds signed 32-bit (4-byte) integers that range in value from -


2,147,483,648 through 2,147,483,647.

Long data type :

Holds signed 64-bit (8-byte) integers ranging in value from -


9,223,372,036,854,775,808 through 9,223,372,036,854,775,807
(9.2...E+18).

Object Data Type :

Holds addresses that refer to objects. You can assign any


reference type (string, array, class, or interface) to an Object
variable. An Object variable can also refer to data of any value
type (numeric, Boolean, Char, Date, structure, or enumeration).

SByte data type :

Holds signed 8-bit (1-byte) integers that range in value from -128
through 127.

Short data type :

Holds signed 16-bit (2-byte) integers that range in value from -


32,768 through 32,767.

Single Data Type :

Holds signed IEEE 32-bit (4-byte) single-precision floating-point


numbers ranging in value from -3.4028235E+38 through -
1.401298E-45 for negative values and from 1.401298E-45
through 3.4028235E+38 for positive values. Single-precision
numbers store an approximation of a real number.

String Data Type (Visual Basic)

Holds sequences of unsigned 16-bit (2-byte) code points that


range in value from 0 through 65535. Each code point, or
character code, represents a single Unicode character. A string
can contain from 0 to approximately two billion (2 ^ 31) Unicode
characters.

UInteger data type :

Holds unsigned 32-bit (4-byte) integers ranging in value from 0


through 4,294,967,295.

ULong data type :

Holds unsigned 64-bit (8-byte) integers ranging in value from 0


through 18,446,744,073,709,551,615 (more than 1.84 times 10 ^
19).

User-Defined Data Type :

Holds data in a format you define. The Structure statement


defines the format. Previous versions of Visual Basic support
the user-defined type (UDT). The current version expands the
UDT to a structure. A structure is a concatenation of one or
more members of various data types. Visual Basic treats a
structure as a single unit, although you can also access its
members individually.

UShort data type :


Holds unsigned 16-bit (2-byte) integers ranging in value from 0
through 65,535.

Data Type Summary (Visual Basic) :

The following table shows the Visual Basic data types, their
supporting common language runtime types, their nominal
storage allocation, and their value ranges.
Visual Basic Common Nominal Value range
type language storage
runtime allocatio
type n
structure
Boolean Boolean Depends True or False
on
impleme
nting
platform
Byte Byte 1 byte 0 through 255 (unsigned)
Char (single Char 2 bytes 0 through 65535 (unsigned)
character)
Date DateTime 8 bytes 0:00:00 (midnight) on
January 1, 0001 through
11:59:59 PM on December
31, 9999
Decimal Decimal 16 bytes 0 through +/-
79,228,162,514,264,337,593
,543,950,335 (+/-
7.9...E+28) † with no
decimal point; 0 through +/-
7.922816251426433759354
3950335 with 28 places to
the right of the decimal;

smallest nonzero number is


+/-
0.000000000000000000000
0000001 (+/-1E-28) †
Double (dou Double 8 bytes -
ble-precision 1.79769313486231570E+30
floating- 8 through -
point) 4.94065645841246544E-
324 † for negative values;

4.94065645841246544E-
324 through
1.79769313486231570E+30
8 † for positive values
Integer Int32 4 bytes -2,147,483,648 through
2,147,483,647 (signed)
Long (long Int64 8 bytes -9,223,372,036,854,775,808
integer) through
9,223,372,036,854,775,807
(9.2...E+18 †) (signed)
Object Object (clas 4 bytes Any type can be stored in a
s) on 32-bit variable of type Object
platform

8 bytes
on 64-bit
platform
SByte SByte 1 byte -128 through 127 (signed)
Short (short Int16 2 bytes -32,768 through 32,767
integer) (signed)
Single (singl Single 4 bytes -3.4028235E+38 through -
e-precision 1.401298E-45 † for negative
floating- values;
point)
1.401298E-45 through
3.4028235E+38 † for
positive values
String (varia String (clas Depends 0 to approximately 2 billion
ble-length) s) on Unicode characters
impleme
nting
platform
UInteger UInt32 4 bytes 0 through 4,294,967,295
(unsigned)
ULong UInt64 8 bytes0 through
18,446,744,073,709,551,615
(1.8...E+19 †) (unsigned)
User- (inherits Depends Each member of the
Defined (str from Value on structure has a range
ucture) Type) impleme determined by its data type
nting and independent of the
platform ranges of the other members
UShort UInt16 2 bytes 0 through 65,535 (unsigned)


In scientific notation, "E" refers to a power of 10. So 3.56E+2
signifies 3.56 x 102 or 356, and 3.56E-2 signifies 3.56 / 102 or
0.0356.

- Discussion :

1- Name five data types in VB and show their range ?

2- What is the difference between UShort and Ulong data type


in VB ?

*****

Sources :

1- Murach's Visual Basic 2015 , Anne Boehm (Author), Mike


Murach (Editor) , 6th Edition , Mike Murach & Associates
Publishers , 2016 .

2- https://docs.microsoft.com/en-us/dotnet/visual-basic.

Вам также может понравиться