Table of Contents

Class VBStringValue

Namespace
RDCore.SDK.Model.Values.Intrinsic
Assembly
RDCore.SDK.dll

Represents and holds a String value.

public record VBStringValue : VBTypedValue, IEquatable<VBTypedValue>, IVBTypedValue<VBStringValue, string>, IEquatable<IVBTypedValue<VBStringValue, string>>, IEquatable<VBStringValue>
Inheritance
VBStringValue
Implements
Derived
Inherited Members

Constructors

VBStringValue(IBindingHandle)

Creates a new VBStringValue.

public VBStringValue(IBindingHandle handle)

Parameters

handle IBindingHandle

VBStringValue(string)

Creates a new VBStringValue.

public VBStringValue(string value)

Parameters

value string

Fields

NaN

The text of NaN, let-coerced to a String (MS-VBAL §5.5.1.2.4): -nan(ind), as MS-VBA has it.

public const string NaN = "-nan(ind)"

Field Value

string

Remarks

MS-VBAL specifies -1.#IND; MS-VBA gives -nan(ind) for the NaN an invalid operation yields - 0 / 0, infinity less infinity (recorded in Excel), whose sign bit is set.

NegativeInfinity

The text of negative infinity, let-coerced to a String (MS-VBAL §5.5.1.2.4): -inf, as MS-VBA has it.

public const string NegativeInfinity = "-inf"

Field Value

string

Remarks

MS-VBAL specifies the same 1.#INF as for positive infinity, which looks like a transcription error; MS-VBA gives -inf (recorded in Excel).

PositiveInfinity

The text of positive infinity, let-coerced to a String (MS-VBAL §5.5.1.2.4): inf, as MS-VBA has it.

public const string PositiveInfinity = "inf"

Field Value

string

Remarks

MS-VBAL specifies 1.#INF, the text of older C runtimes; MS-VBA gives inf (CStr, Format; recorded in Excel).

PositiveNaN

The text of a NaN whose sign bit is clear, let-coerced to a String: nan, as MS-VBA has it - what Abs makes of the NaN of an invalid operation (recorded in Excel).

public const string PositiveNaN = "nan"

Field Value

string

Zero

public const string Zero = "0"

Field Value

string

Properties

ByteLength

The number of bytes the string's data occupies: two per character, and one more for a TrailingByte.

public int ByteLength { get; }

Property Value

int

Remarks

👉 Measured through Length, so a fixed-length string counts every character of its declared length.

IsNullString

Whether this is vbNullString — a String bound to a null pointer rather than to a zero-length string.

public bool IsNullString { get; }

Property Value

bool

Remarks

The only observable difference between the two in MS-VBA is the pointer: vbNullString = "" is True and Len(vbNullString) is 0, but a null pointer occupies no string storage, which is what Size reports and this tells it.

Length

public virtual int Length { get; }

Property Value

int

Size

The allocated size (in bytes) of this value.

public override int Size { get; }

Property Value

int

TrailingByte

The byte left over after the last whole character when the string's data is an odd number of bytes, or null when it is not.

public byte? TrailingByte { get; }

Property Value

byte?

Remarks

A Byte() with an odd number of elements Let-coerced to String is one (MS-VBAL §5.5.1.2.6): the bytes are "interpreted as if [they represent] the implementation-defined binary format used to store String data", and RDCore's format keeps every one of them (VBRuntimeByteStringValue).

VBNullString

Gets the static value of vbNullString.

public static VBStringValue VBNullString { get; }

Property Value

VBStringValue

Value

The characters of the string: every whole code unit of its data.

public string Value { get; }

Property Value

string

Remarks

👉 A TrailingByte is not a character, so it is not here: this is what Len counts and what a character-by-character reader sees.

ZeroLengthString

Gets the static value of the zero-length empty string.

public static VBStringValue ZeroLengthString { get; }

Property Value

VBStringValue

Methods

Concat(VBStringValue, VBStringValue)

The string whose data is the data of lhs followed by the data of rhs.

public static VBStringValue Concat(VBStringValue lhs, VBStringValue rhs)

Parameters

lhs VBStringValue

The string whose data comes first.

rhs VBStringValue

The string whose data comes after it.

Returns

VBStringValue

Remarks

Two strings of whole characters join their characters. A TrailingByte on the left pairs with the first byte on the right, so every character after it is made of a different pair of bytes than before.

Equals(IVBTypedValue<VBStringValue, string>?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(IVBTypedValue<VBStringValue, string>? other)

Parameters

other IVBTypedValue<VBStringValue, string>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(VBStringValue?)

Two String values are equal when they hold the same characters and the same TrailingByte, if any.

public virtual bool Equals(VBStringValue? other)

Parameters

other VBStringValue

Returns

bool

Remarks

👉 The managed value VBTypedValue's own equality keys on is the characters only, which two strings differing in a trailing byte share.

FromBytes(ReadOnlySpan<byte>)

The String whose data is bytes, every one of them kept: an odd number leaves a TrailingByte.

public static VBStringValue FromBytes(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

The data of the string, two bytes per character, little-endian.

Returns

VBStringValue

FromLiteralToken(string)

Creates a VBStringValue from the source text of a MS-VBAL 3.3.4 <STRING> token — the literal as it is spelled in source, delimiters included.

public static VBStringValue FromLiteralToken(string token)

Parameters

token string

The token's source text. Leading and trailing double-quote delimiters are removed when present; text carrying none is taken as-is, so a caller holding an already-unquoted value can pass it through without first having to tell the two apart.

Returns

VBStringValue

Remarks

MS-VBAL 3.3.4: "a sequence of two <double-quote> characters represents a single occurrence of the character U+0022 within the data value" — a literal's data value is therefore never its source text, and slicing off the delimiters alone leaves every embedded quote doubled.

GetBytes()

The data of the string: two bytes per character, little-endian, then the TrailingByte when there is one.

public byte[] GetBytes()

Returns

byte[]

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

UnquoteLiteralToken(string)

Gets the data value (MS-VBAL 2.1) of a MS-VBAL 3.3.4 <STRING> token from its source text.

public static string UnquoteLiteralToken(string token)

Parameters

token string

The token's source text. Leading and trailing double-quote delimiters are removed when present; text carrying none is taken as-is.

Returns

string

Remarks

The string counterpart of FromLiteralToken(string), for callers that need the data value itself rather than a value bound to it.

WithValue(string?)

Returns a copy of this value holding value.

public virtual VBStringValue WithValue(string? value)

Parameters

value string

Returns

VBStringValue

Remarks

👉 A string is whole characters, so the copy never has a TrailingByte.