Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Specific meaning and examples of conversion function.
Specific meaning and examples of conversion function.
Various data type conversion functions in VB

1. Various decimal conversion functions

Universal databases include decimal, binary and hexadecimal. Decimal system is the data base used in our daily life, so it is also the most familiar and clear. Binary system is the basic system of computer, mainly because it is easy to realize binary system with physical devices; Octal and hexadecimal have a natural close relationship with binary and are more convenient to express than binary, so they have become common representations of computers.

The conversion functions between databases involved in VB mainly include the following: hexadecimal function: returning a string representing hexadecimal value; Oct function: returns a variant (string) representing the octal value of a numerical value; Cint function: forces the expression to be converted into an integer between-32,768 and 32,767;

CLng function: cast an expression into a long integer of -2,147,483,648 to 2,147,483,647; Cdec function: forces the expression to be converted to decimal data type; CDbl function: force the expression to be converted to Double data type;

These functions are the most basic conversion functions between databases, among which the first three functions are the most commonly used and useful. As can be seen from the above functions, VB does not provide us with a special function to convert expressions or data into decimal and binary, but decimal conversion can be easily completed by Cint function, while binary implementation can be easily converted through the relationship between binary, octal and hexadecimal.

The following examples are examples of Hex function, Oct function and Cint function: (1). A= hex(5) returns 5; (2).B=hex( 10) gives A (3). C=hex(23) returns 17 (4). D=oct(5) gives 5 (5). E=oct( 10) gives 65438.

(7).g = Cint(& amp; H 17) gives 23 (8). h = cint(&; O 12) returns 10.

The application of these functions is relatively simple, so I won't say more. It is worth mentioning that both Hex function and Oct function return strings. If you want to convert hexadecimal or octal string variables into decimal, you can do this: c = "17" 17 is the string c =" &;; H " & ampC

Ic=Cint(C) gives 23.