3.2.1 Data Type

Source: Internet
Author: User

The data type determines how the computer stores data, memory space occupied, data ranges that can be expressed, and data processing methods. VB. NET provides a wide range of basic data types and allows you to define new data types.

1. Basic data type
The basic data type is the data type defined by the system, including the numeric data type, byte type, logical type, date type, character type, string type, and object type.
(1) Numeric) Data Type
The numeric data types are Integer, Long, Single, Double, and Decimal. Their table number range and byte count are listed in Table 3-1.
Table 3-1 numeric data types of VB. NET
Data Type value range Byte Count
Integer-2147483648 ~ 2147483647 4
Long 9223372036854775808 ~ 9223372036854775807 8
Short-32768 ~ 32767 2
Single-3.402823E38 ~ -1.401298E-451.041298E-45 ~ 3.402823E38 4
Double-1.7976313486231E308 ~ 4.94065645841247E-324.
4.94065645841247E-324 ~ 1.79769313486231E308
Decimal-7922816251426433759354 ~ 79228162514264337593543950335
The number of non-0 values with the smallest absolute value: +/-0.000000000000000000000000001 12
(2) Byte) Data Type
The byte type is used to store binary data, which occupies 1 byte and has a value range of 0 ~ The integer of 255, which is an unsigned data type. When converting ANSI and Unicode formats, if the data is stored in Byte format, the original value can be retained. If the data is stored in String format, it may be damaged. When reading, writing, calling DIL, and calling object methods and attributes, VB. NET will automatically convert between ANSI and Unicode. Note that all operators that take effect on integers except the unary minus sign can be used for data of the Byte type.
(3) logical Boolean) Data Type
Logical Data occupies 2 bytes, which is mainly used to store the results of logical judgment. The values are logical values (True) or False ). When other data types are converted to Logical Data, convert non-0 to True, and convert 0 to False.
(4) Date) Data Type
The Date type is used to save the Date and time data, which is 8 bytes. The value range is 1-1-0001 0:00:00 ~ 12-31-9999 23:59:59 date, that is, the date range is from January 1, to January 1 ~ January 1, December 31, 9999, with a time range of 0:00:00 ~ 23:59:59. "#" Must be added before and after the Date value. The format of the Date value is m-d-yyyy hh: mm: ss month-day-year hour: minute: seconds ). Example: #10:20:18 #.
(5) Char type
Bytes data occupies 2 bytes and the value range is 0 ~ 65535 represents a Unicode character. Implicit conversion is not allowed between the Char data type and the numeric data type, but the Char data display can be converted to the numeric data using the system Asc () or AscW.
(6) String) Data Type
The String type is used to store String data. One character occupies 1 byte, and one Chinese Character occupies 2 bytes. the maximum length of a String can be 2 billion or 231 characters. "" Must be added before and after the string "". Example: "Good morning! "," Program ".
(7) Object) Data Type
The Object type is used to store objects in applications. It can store any type of data, 4 bytes.

2. Custom Data Types
The user-defined type is in Visual Basic. NET), contains one or more different types of data, depending on the custom type of members to decide the stored data, the keyword is System. valueType. The memory space occupied by user-defined data types is the total memory space occupied by all data types it contains.


BibliographyPrevious sectionNext section

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.