Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Vb data type conversion
Vb data type conversion
CType(X)

[Format]:

P=CBool(X)' Convert x to Boolean type.

P=CByte(X)' Converts x to "byte" type.

P=CCur(X)' Convert x to currency type.

P=CDate(X)' Convert x to "date" type.

P=CDbl(X)' Convert x to "Double" type.

P=CInt(X)' Converts x to "integer" type.

P=CLng(X)' Convert x to "Long" type.

P=CSng(X)' Convert x to "Single" type.

P=CStr(X)' Convert x to "string" type.

P=Cvar(X)' Convert x to variable type.

P=CVErr(X)' converts x into an error value.

[example]:

(1). CSTR (13)+CSTR (23)' is converted into a string, and then connected with "+". The result is 1323.

(2).CInt(" 12")+ 12' string is converted into an integer, and 12 is added, and the result is 24.

(3). p = INT (true)' The output result is-1' When converting a Boolean value into a numerical value, it should be noted that there are only true and false Boolean values, where the true value is-1 in memory and the false value is stored as 0.

(4).CBool(-0.00 1)' output result is true.

When converting a numeric value to a Boolean value, a numeric value equal to 0 will be False, and a numeric value not equal to 0 will be True.

2.Int(X), Fix(X): take the integer value of x.

[Format]:

P=Int(X)' take

P=Fix(X)' Take the integer part of x and remove the decimal directly.

[example]:

(1) Int(-54.6) "the result is -55, take

(2) Fix(54.6)' The result is 54. Take the integer and directly remove the decimal.

The definition of data type in 1. data structure is a set of values and a set of operations defined on this set of values.

2. Variables are places where values are stored. They have names and data types. The data type of variables determines how the bits representing these values are stored in computer memory. When you declare a variable, you can also specify its data type. All variables have data types to determine what kind of data can be stored.

3. Data types include primitive type, multivariate group, record unit, algebraic data type, abstract data type, reference type and function type.