Converting - Explicit
All explicit data type conversion must be done using a Data Type Conversion Function.
All the conversion functions can automatically handle locale issues
That means that they will take international date/time and number regional settings into account.
Double to Integer
Dim myDouble As Double
Dim myInteger As Integer
myDouble = 10.6
myInteger = CInt(myDouble)
Debug.Print myInteger // 11
CBOOL | Returns the expression converted to a boolean data type (Boolean). Converts any valid string or numeric expression to a boolean. |
CBYTE | Returns the expression converted to a byte data type (Byte). Converts numeric expressions 0-255 to Byte. Rounds fractional parts. |
CCUR | Returns the expression converted to a currency data type (Currency). |
CCHAR | Only available in VB.Net |
CDATE | Returns the expression converted to a date data type (Date). Converts any valid date or time representations to the Date type. |
CDBL | Returns the expression converted to a double data type (Double). Converts any expression that can be evaluated as a number to a Double (assuming it is in the range of a Double). |
CDEC | Returns the expression converted to a variant/decimal subtype (Variant). Converts any expression that can be evaluated as a number to a Decimal. |
CINT | Returns the expression converted to an integer data type (Integer). Converts any expression that can be evaluated as a number to an Integer. Rounds fractional parts. |
CLNG | Returns the expression converted to a long data type (Long). Converts any expression that can be evaluated as a number to a Decimal. |
CLNGLNG | Returns the expression converted to a long data type (64 bit only) (Long). Converts any expression that can be evaluated as a number to a Decimal. |
CLNGPTR | Returns the expression converted to a longptr data type. |
COBJ | Only available in VB.Net |
CSBYTE | Only available in VB.Net |
CSHORT | Only available in VB.Net |
CSNG | Returns the expression converted to a single data type (Single). |
CSTR | Returns the expression converted to a string data type (String). |
CVAR | Returns the expression converted to a variant data type (Variant). |
CVDATE | Returns the expression converted to a variant/date subtype (Variant). |
CVERR | Returns the corresponding to a given error number (Variant). |
Backwards Compatibility
These are only included for backwards compatibility and should not to used.
If you have any problems with the Int() or Cint() type conversion functions then use the Str() function to return a string representation of the number first, before converting.
INT* | Returns the number rounded down to the nearest integer (Double). |
STR* | Returns the text string of a number (String). |
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext