Connectivity Software User's Guide and Reference
NumericalValue Property (_VarType)
Example 



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.ComInterop.ComTypes Namespace > _VarType Interface : NumericalValue Property
The numerical (integer) value of the data type.
Syntax
'Declaration
 
<ValueLimitsAttribute(0, 65535)>
Property NumericalValue As Integer
'Usage
 
Dim instance As _VarType
Dim value As Integer
 
instance.NumericalValue = value
 
value = instance.NumericalValue
[ValueLimits(0, 65535)]
int NumericalValue {get; set;}
[ValueLimits(0, 65535)]
property int NumericalValue {
   int get();
   void set (    int value);
}

Property Value

The default value of this property is 0.

Exceptions
ExceptionDescription

The value of an argument is outside the allowable range of values as defined by the invoked method.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks

For the list of numerical values, see e.g. https .

This member or type is for use from COM. It is not meant to be used from .NET or Python. Refer to the corresponding .NET member or type instead, if you are developing in .NET or Python.

Example
// Shows how to write into multiple OPC items using a single method call, specifying their requested data types.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

var varTypes_I2 = 2;
var varTypes_R4 = 4;

// Instantiate the client object.
var Client = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

WScript.Echo("Writing multiple item values...");

// Prepare the arguments

var requestedDataType1 = new ActiveXObject("OpcLabs.BaseLib.ComInterop.VarType");
requestedDataType1.NumericalValue = varTypes_I2;
var WriteValueArguments1 = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemValueArguments");
WriteValueArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2";
WriteValueArguments1.ItemDescriptor.ItemId = "Simulation.Register_I2";
WriteValueArguments1.ItemDescriptor.RequestedDataType = requestedDataType1; // the requested data type
WriteValueArguments1.Value = 12345;

var requestedDataType2 = new ActiveXObject("OpcLabs.BaseLib.ComInterop.VarType");
requestedDataType2.NumericalValue = varTypes_R4;
var WriteValueArguments2 = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemValueArguments");
WriteValueArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2";
WriteValueArguments2.ItemDescriptor.ItemId = "Simulation.Register_R4";
WriteValueArguments2.ItemDescriptor.RequestedDataType = requestedDataType2; // the requested data type
WriteValueArguments2.Value = 234.56;

var dictionary = new ActiveXObject("Scripting.Dictionary");
dictionary.Add(0, WriteValueArguments1);
dictionary.Add(1, WriteValueArguments2);
var items = dictionary.Items();

// Perform the write operations.
var results = Client.WriteMultipleItemValues(items);

// Display results.
var jsArray = results.toArray();
for (i = 0; i < jsArray.length; i++) {
    var WriteResult = jsArray[i]
    if (WriteResult.Succeeded)
        WScript.Echo("Result " + i + ": Success");
    else
        WScript.Echo("Result " + i + " *** Failure: " + WriteResult.Exception.GetBaseException().Message);
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also