Home > Common Problem > How many basic data types are there in vb?

How many basic data types are there in vb?

青灯夜游
Release: 2023-01-13 00:25:14
Original
39906 people have browsed it

There are 9 basic data types in VB, namely: character data type, numeric data type (integer, long integer, single-precision floating point, double-precision floating point), currency type , byte type, Boolean type, date type, generic type, unsigned type, object type.

How many basic data types are there in vb?

The basic data types provided by VB 6.0 mainly include: character data, numerical data, currency type, byte type, Boolean type, date type, general There are 9 data types such as type, unsigned type, and object type.

1. Character data

Character data (String) is used to define a character sequence. One character is stored in memory using one byte.

2. Numerical data

Numerical data includes 4 types: integer, long integer, and floating point (single precision and double precision).

(1) Integer number

Integer (Integer): It is a number without decimal point, ranging from -32 768 to 3 2 767, using 2 bytes (1 6 bits) to store an integer. A number between -32 678 and 32 767 with a "%" sign at the end also represents an integer data, such as 1 345%, -67%. '

(2) Long integer number

Long integer number (Long): It exceeds the range of 32 768~32 767, and is in the range of -2 147 483 648~2 1 47 483 A number between 647 without a decimal point. A long integer occupies 4 bytes (32 bits) in memory. Numbers between -2 1 47 483 648 and 2 1 47 483 647 have an "&" symbol at the end and are also expressed as a long integer.

(3) Floating point number

Single precision number (Single): It is a real number with a decimal point, and the effective value is 7 digits. Use 4 bytes (32 bits) to store a single-precision number in memory. Usually expressed in exponential form (scientific notation), with "E" or "e" representing the exponent part.

Double precision data (Double): It is also a real number with a decimal point, and the valid value is 1 5 digits. Use 8 bytes (64 bits) to store a double-precision number in memory. Double-precision numbers are usually expressed in exponential form (scientific notation), with "D" or "d" representing the exponent part.

3. Currency type

Currency type (Currency): It is a fixed-point data type set for currency calculation. It has high precision requirements and is accurate to 4 decimal places. Occupies 8 bytes (64 bits) in memory. The value range is between -922 337 203 685 477.5805 and 922 337 203 685 477.5807.

4. Byte type

Byte type: It is a numerical type, stored as a 1-byte unsigned binary number, with a value range of 0~255.

5. Boolean type

Boolean type (Boolean): Boolean data is a logical value, also called a logical type. It is stored in two bytes. It only takes two values, namely 'Frue (true) or False ( Fake).

6. Date type

Date type (Date): Used to represent dates. A date type data uses 8 bytes to store in the memory.

7. Universal type

Universal type (’Variant), also called variant type, is a general, variable data type that can represent any of the above data types. Suppose a is defined as a general variable.

Dim a As Variant

Any type of data can be stored in variable a, for example:

a: --BASIC' - stores a string

a=10 - stores an integer

a=20.5 - stores a real number

a=--08/15/2003'· 'Stores a date data

According to the type of the value assigned to a, the type of variable a constantly changes, which is why it is called a variant type. When a variable has an undefined type, VB automatically defines the variable as a Variant type. Different types of data are stored in Variant variables according to their actual types (for example, assign an integer to a and store it in the memory area as an integer). The user does not need to do any conversion work, VB automatically completes it.

8. Unsigned type

Unsigned type (Decimal): The variable stores a 96-bit (1 2 bytes) unsigned integer form, and is divided by a power of 1 O, which is called the variable ratio factor. This ratio factor determines the number of digits to the right of the decimal point, ranging from 0 to 28.

Note: Currently, the Decimal data type can only be used in variant types (Variant), that is to say, a variable cannot be declared as Decimal. type.

9. Object type

Object type (Object): used to represent graphics, OLE objects or other objects, stored in 4 bytes.

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of How many basic data types are there in vb?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template