Data Types

1.4 Data Types

Whether VB is a weakly or a semi-strongly typed language depends on the OptionExplicit setting. (The statement must appear at the top of a code module.) If Off, VB is a weakly typed language; variables need not be declared in advance, and all undeclared variables will be cast as type Object until they are initialized. If On (its default setting), each variable must be declared in advance, but its data type need not be specified. If no type is explicitly declared, variables are cast as type Object until their first use.

Although VB recognizes a number of "intrinsic" data types, each is really a wrapper around a data type found in the .NET Common Type System (CTS). VB recognizes the following intrinsic types:

Boolean

A logical (True or False) value. Corresponds to System.Boolean.

Byte

A signed 8-bit numeric data type. Corresponds to System.Byte.

Char

A 16-bit character data type (character code). Corresponds to System.Char.

Date

A date or time value. Corresponds to System.DataTime.

Decimal

A decimal or currency value. Corresponds to System.Decimal.

Double

A double-precision floating point value. Corresponds to System.Double.

Integer

A signed 32-bit integral data type. Corresponds to System.Int32.

Long

A signed 64-bit integral data type. Corresponds to System.Int64.

Object

A reference to an object. Object is VB's "universal" data type and corresponds to System.Object.

Short

A signed 16-bit integral data type. Corresponds to System.Int16.

Single

A single-precision floating point value. Corresponds to System.Single.

String

A reference type pointing to a fixed-length character string. Corresponds to System.String.

A number of other data types are available from the .NET CTS but are not wrapped by a corresponding VB intrinsic data type. These include:

System.SByte

A signed 8-bit integral data type.

System.UInt16

An unsigned 16-bit integral data type.

System.UInt32

An unsigned 32-bit integral data type.

System.UInt64

An unsigned 64-bit integral data type.

VB also allows you to create user-defined reference types by using the Class...EndClass construct and user-defined value types by using the Structure...EndStructure construct.

Any of these data types can be used as a member of an array. Arrays can have a single dimension, or they can be multidimensional (up to 60 dimensions). The first element in an array is always at position 0.

 



VB. NET Language Pocket Reference
VB.NET Language Pocket Reference
ISBN: 0596004281
EAN: 2147483647
Year: 2002
Pages: 31

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net