Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert Boolean type and numerical type in VB?
How to convert Boolean type and numerical type in VB?
[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=CInt(True)' The output result is-1.

When converting a Boolean value into a numerical value, it should be noted that a Boolean value has only a true value and a false value, 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 an integer and remove the decimal directly.