Table of Contents

Class VBCurrencyType

Namespace
RDCore.SDK.Model.Types
Assembly
RDCore.SDK.dll

A VBNumericType<T> representing the Currency data type.

public sealed record VBCurrencyType : VBNumericType<VBRuntimeCurrencyValue>, IEquatable<VBType>, IEquatable<VBIntrinsicType>, IEquatable<VBNumericType>, IEquatable<VBNumericType<VBRuntimeCurrencyValue>>, IFixedPointNumericType, INumericType, IEquatable<VBCurrencyType>
Inheritance
VBCurrencyType
Implements
Inherited Members
Extension Methods

Remarks

The managed type of a value of this data type is decimal.
👉 Implements IFixedPointNumericType.

Constructors

VBCurrencyType()

A VBNumericType<T> representing the Currency data type.

public VBCurrencyType()

Remarks

The managed type of a value of this data type is decimal.
👉 Implements IFixedPointNumericType.

Properties

DefaultValue

Gets the default value for this data type.

public override VBTypedValue DefaultValue { get; }

Property Value

VBTypedValue

Remarks

⚠️ Derived types must back the implementation of this property with a thread-safe private static readonly Lazy<T>. Failure to do so would lock up the static context initialization of the StaticSymbol symbols.

ManagedMaxValue

Gets the maximum representable managed (.net) value for this data type.

public override double ManagedMaxValue { get; }

Property Value

double

ManagedMinValue

Gets the minimum representable managed (.net) value for this data type.

public override double ManagedMinValue { get; }

Property Value

double

MaxValue

Gets the maximum representable value for this data type.

public static VBCurrencyValue MaxValue { get; }

Property Value

VBCurrencyValue

MinValue

Gets the minimum representable value for this data type.

public static VBCurrencyValue MinValue { get; }

Property Value

VBCurrencyValue

TypeInfo

The Currency data type.

public static VBCurrencyType TypeInfo { get; }

Property Value

VBCurrencyType

Zero

Gets the value 0 (zero) representation of this data type.

public static VBCurrencyValue Zero { get; }

Property Value

VBCurrencyValue

Methods

CreateValue(IBindingHandle)

Creates a value of this type bound to handle.

public override VBTypedValue CreateValue(IBindingHandle handle)

Parameters

handle IBindingHandle

Returns

VBTypedValue

Remarks

The base implementation throws: only types that can hold a runtime value override this (matches the intent of the removed VBTypedValueFactory.CreateValue(VBType) switch, which returned null for the rest).

CreateValue(double)

Creates a value of this numeric type holding value, converted to this type's managed representation (banker's rounding for integral targets, as per Convert).

public override VBNumericTypedValue CreateValue(double value)

Parameters

value double

Returns

VBNumericTypedValue

Holds(double)

Whether a double is within the range of this type (MS-VBAL 5.5.1.2.1): one a value of this type can be made of (CreateValue(double)) without leaving the range.

public override bool Holds(double value)

Parameters

value double

The value. NaN is within no range.

Returns

bool

Remarks

👉 The base is within ManagedMinValue and ManagedMaxValue, both included, which is right for a type whose bounds are double values. A type whose bound is not one has, as its ManagedMaxValue or ManagedMinValue, the double nearest it, which can be past it: that type overrides this, and leaves out such a bound.

ToDouble(VBRuntimeCurrencyValue)

Converts a Currency to a Double as MS-VBA does: the value rounded to the nearest Double, a tie to the even one (MS-VBAL §5.5.1.2.1).

public static double ToDouble(VBRuntimeCurrencyValue value)

Parameters

value VBRuntimeCurrencyValue

The Currency to convert.

Returns

double

The Double nearest the value: CDbl(CCur("75299393168858.7426")) is 75299393168858.75, where the number of ten-thousandths made a Double, then divided by 10000, is 75299393168858.734375.

Remarks

The value is rounded once (observed in Excel). The result does not depend on the .NET version.

ToSingle(VBRuntimeCurrencyValue)

Converts a Currency to a Single as MS-VBA does: the value rounded to the nearest Single, a tie to the even one (MS-VBAL §5.5.1.2.1).

public static float ToSingle(VBRuntimeCurrencyValue value)

Parameters

value VBRuntimeCurrencyValue

The Currency to convert.

Returns

float

The Single nearest the value: CSng(CCur("281474993487872.0001")) is 281475010265088, where the Double nearest the value, 281474993487872, is halfway between two Single values and rounds to the even one, 281474976710656.

Remarks

The value is rounded once, not through a Double (observed in Excel). The result does not depend on the .NET version.