Skip to main content
Version: 2025

SalVariant

Namespace: PPJ.Runtime.Com

Assembly: PPJ.Web.50 (5.0.0.0)

Stores an automation value and exposes SAL and CLR conversion operations.

public class SalVariant : SalFunctionalClass

Assigning Value updates the associated SAL and automation type codes. The Get methods report unsupported categories through their Boolean result; direct To methods use System.Convert and can throw conversion exceptions.

Example:

using PPJ.Runtime;
using PPJ.Runtime.Com;

var variant = new SalVariant(42);
SalNumber number = 0;
if (variant.GetNumber(ref number))
System.Console.WriteLine(number.ToInt32());

Constructors​

Instance member SalVariant()​

Initializes an empty variant.

Instance member SalVariant(value)​

Initializes a variant with the supplied value.

NameTypeDescription
valueObjectThe value to store.

Properties​

Static member Optional​

SalVariant: Gets a new variant containing Type.Missing for an omitted optional automation argument.

Instance member Value​

Object: Gets or sets the stored value and updates its SAL and automation type codes.

Methods​

Instance member ActiveXType()​

Gets the automation category of the stored value.

Returns: SalNumber. The COM VarEnum value.

Instance member AsActiveX(vt)​

Converts and replaces the stored value using a supported automation scalar type.

ParameterTypeDescription
vtSalNumberThe target COM VarEnum type code.

Returns: SalBoolean. True after conversion; false if the type is unsupported.

Supports strings, dates, numeric types, decimals, and currency; unsupported type codes return false. Conversion failures can throw.

Instance member GetBlob(s)​

Reads an array variant as binary SAL string data.

ParameterTypeDescription
s by referenceSalStringReceives the converted value when the category is supported.

Returns: SalBoolean. True for an array or empty variant; otherwise, false.

A byte array supplies the binary data. Other arrays and empty variants produce SalString.Null.

Instance member GetBoolean(b)​

Converts a Boolean, numeric, string, date, or empty variant to a SAL Boolean.

ParameterTypeDescription
b by referenceSalBooleanReceives the converted value when the category is supported.

Returns: SalBoolean. True when the category is supported and processing completes; otherwise, false.

An empty variant becomes false; a non-null date becomes true.

Instance member GetDate(d)​

Converts a date, string, or empty variant to a SAL date/time.

ParameterTypeDescription
d by referenceSalDateTimeReceives the converted value when the category is supported.

Returns: SalBoolean. True when the category is supported and processing completes; otherwise, false.

Instance member GetNumber(num)​

Converts a numeric, Boolean, string, or empty variant to a SAL number.

ParameterTypeDescription
num by referenceSalNumberReceives the converted value when the category is supported.

Returns: SalBoolean. True when the category is supported and processing completes; otherwise, false.

Boolean true converts to -1; an empty variant yields SalNumber.Null.

Instance member GetObject(obj)​

Assigns an object variant to the supplied automation wrapper.

ParameterTypeDescription
objSalObjectThe destination object wrapper.

Returns: SalBoolean. True for an object or empty variant; otherwise, false.

An empty variant assigns null to the wrapper.

Instance member GetSafeArray(array)​

Wraps an array variant as a SalSafeArray.

ParameterTypeDescription
array by referenceSalSafeArrayReceives the converted value when the category is supported.

Returns: SalBoolean. True for an array or empty variant; otherwise, false.

An empty variant creates a wrapper whose Value is null.

Instance member GetString(s)​

Converts the stored value to a SAL string when it implements IConvertible.

ParameterTypeDescription
s by referenceSalStringReceives the converted value when the category is supported.

Returns: SalBoolean. True when processing completes; false if conversion throws.

Empty and nonconvertible values produce a null SAL string.

Instance member MakeOptional()​

Replaces the stored value with Type.Missing for an omitted optional argument.

Instance member SalType()​

Gets the SAL category of the stored value.

Returns: SalNumber. The Sys.SAL_* category code.

Instance member SetBlob(s)​

Stores the binary byte array from the SAL string.

ParameterTypeDescription
sSalStringThe SAL text or binary value to store.

Returns: SalBoolean. True after assignment.

Instance member SetBoolean(b)​

Stores the boolean value.

ParameterTypeDescription
bSalBooleanThe Boolean value to store.

Returns: SalBoolean. True after assignment.

Instance member SetDate(d)​

Stores the date value.

ParameterTypeDescription
dSalDateTimeThe date/time value to store.

Returns: SalBoolean. True after assignment.

Instance member SetNumber(num, vt_type)​

Stores a number converted to the requested automation numeric type.

ParameterTypeDescription
numSalNumberThe numeric value to store.
vt_typeSalNumberThe supported automation numeric type code.

Returns: SalBoolean. True after assignment.

Unsupported type codes throw ArgumentException.

Instance member SetObject(o)​

Stores the attached object from the wrapper.

ParameterTypeDescription
oSalObjectThe object wrapper whose Value is stored.

Returns: SalBoolean. True after assignment.

Instance member SetSafeArray(array)​

Stores the managed array from the wrapper.

ParameterTypeDescription
arraySalSafeArrayThe array wrapper whose Value is stored.

Returns: SalBoolean. True after assignment.

Instance member SetString(s)​

Stores the string value.

ParameterTypeDescription
sSalStringThe SAL text or binary value to store.

Returns: SalBoolean. True after assignment.

Instance member ToByte()​

Converts the stored value to a unsigned 8-bit integer.

Returns: Byte. The converted value.

Instance member ToCurrency()​

Converts the stored value to a COM currency wrapper.

Returns: CurrencyWrapper. The converted value.

Instance member ToDateTime()​

Converts the stored value to a date/time.

Returns: DateTime. The converted value.

Instance member ToDecimal()​

Converts the stored value to a decimal number.

Returns: Decimal. The converted value.

Instance member ToDouble()​

Converts the stored value to a double-precision floating-point number.

Returns: Double. The converted value.

Instance member ToInt16()​

Converts the stored value to a signed 16-bit integer.

Returns: Int16. The converted value.

Instance member ToInt32()​

Converts the stored value to a signed 32-bit integer.

Returns: Int32. The converted value.

Instance member ToInt64()​

Converts the stored value to a signed 64-bit integer.

Returns: Int64. The converted value.

Instance member ToSByte()​

Converts the stored value to a signed 8-bit integer.

Returns: SByte. The converted value.

Instance member ToSingle()​

Converts the stored value to a single-precision floating-point number.

Returns: Single. The converted value.

Instance member ToUInt16()​

Converts the stored value to a byte and widens it to an unsigned 16-bit result.

Returns: UInt16. The converted byte value represented as UInt16.

The implementation uses Convert.ToByte, so values outside the byte range can throw OverflowException.

Instance member ToUInt32()​

Converts the stored value to a unsigned 32-bit integer.

Returns: UInt32. The converted value.

Instance member ToUInt64()​

Converts the stored value to a unsigned 64-bit integer.

Returns: UInt64. The converted value.