Conversion: CInt64

CInt64

Converts a value to a 64-bit signed integer.



 Public Function CInt64(
	  ByRef Value As Variant ) As Int64

Parameters

Value
[ByRef] Variant. The value to be converted

Return Values

Int64 -  Returns a 64-bit signed integer.

Remarks

This method will attempt to convert various data types to an Int64 value.
TypeOperation
Int64 Returns value.
String Attemps to parse the string expression using Int64.Parse.
Long
-or-
Integer
-or-
Byte
Directly assigns to LowPart in the Int64 and sets the HighPart to -1 if the value is negative.
Double
-or-
Single
-or-
Currency
-or-
Decimal
Assigns the value rounding off any fractions using Round.

Exceptions

ExceptionCondition
InvalidCastException Count not convert from specified type.
OverflowException Value represented a value outside the Int64 valid range from MinValue to MaxValue.

Examples

The following code demonstrates the various types that can be converted.

Public Sub Main()
    ConvertValue "80278098"
    ConvertValue "0xffff"
    ConvertValue CLng(-223432)
    ConvertValue CInt(23214)
    ConvertValue CByte(255)
    ConvertValue CDbl(1234.4323)
    ConvertValue CSng(1234.43)
    ConvertValue CCur(492398.724)
    ConvertValue CDec(492398.724)
End Sub

Private Sub ConvertValue(ByRef Value As Variant)
    Dim x As Int64
    
    x = CInt64(Value)
    
    Debug.Print CorString.Format("{0} of {1} = {2}", TypeName(Value), Value, x)
End Sub

' This code produces the following output.
'    String of 80278098 = 80278098
'    String of 0xffff = 65535
'    Long of -223432 = -223432
'    Integer of 23214 = 23214
'    Byte of 255 = 255
'    Double of 1234.4323 = 1234
'    Single of 1234.43 = 1234
'    Currency of 492398.724 = 492399
'    Decimal of 492398.724 = 492399

See Also

Project CorLib Overview

Class Conversion Overview

Int64Static

Constructors