QuickOPC User's Guide and Reference
Examples - OPC Unified Architecture - Write a single value
View with Navigation Tools

One-time write:

.NET

// This example shows how to write a value into a single node.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class WriteValue
    {
        public static void Main1()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            // Instantiate the client object.
            var client = new EasyUAClient();

            Console.WriteLine("Modifying value of a node...");
            try
            {
                client.WriteValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10221", 12345);
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
                return;
            }

            Console.WriteLine("Finished.");
        }
    }
}

COM

// This example shows how to write a value into a single node.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "WriteValue.h"

namespace _EasyUAClient
{
    void WriteValue::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // Instantiate the client object
            _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));

            // Perform the operation
            ClientPtr->WriteValue(
                //L"http://opcua.demo-this.com:51211/UA/SampleServer", 
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
                L"nsu=http://test.org/UA/Data/ ;i=10221",
                12345);
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}

Incrementing write:

.NET

// This example shows how to write an ever-incrementing value to an OPC UA variable.

using System;
using System.Threading;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class WriteValue
    {
        public static void Incrementing()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"
            UANodeId nodeId = "nsu=http://test.org/UA/Data/ ;i=10221";
            // Example settings with Softing dataFEED OPC Suite: 
            //UAEndpointDescriptor endpointDescriptor =
            //    "opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1";
            //UANodeId nodeId = "nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4";

            // Instantiate the client object
            var client = new EasyUAClient();

            //
            int i = 0;

            do
            {
                Console.WriteLine($"@{DateTime.Now}: Writing {i}");
                try
                {
                    client.WriteValue(endpointDescriptor, nodeId, i);
                }
                catch (UAException uaException)
                {
                    Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                    return;
                }
                i = unchecked((i + 1) & 0x7FFFFFFF);
                Thread.Sleep(2 * 1000);
            } while (!Console.KeyAvailable);
        }
    }
}

COM

Rem This example shows how to write an ever-incrementing value to an OPC UA variable.

Option Explicit

Const endpointDescriptorUrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
Const nodeIdExpandedText = "nsu=http://test.org/UA/Data/ ;i=10221"
' Example settings with Softing dataFEED OPC Suite: 
'Const endpointDescriptorUrlString = "opc.tcp://localhost:4980/Softing_dataFEED_OPC_Suite_Configuration1"
'Const nodeIdExpandedText = "nsu=Local%20Items ;s=Local Items.EAK_Test1.EAK_Testwert1_I4"

' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")

' 
Dim i: i = 0

Do While True
    WScript.Echo "@" & Time & ": Writing " & i
    On Error Resume Next
    Client.WriteValue endpointDescriptorUrlString, nodeIdExpandedText, i
    If Err.Number <> 0 Then
        WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
        WScript.Quit
    End If
    On Error Goto 0
    i = (i + 1) And &H7FFFFFFF
    WScript.Sleep 2*1000
Loop
See Also

Conceptual

Examples - OPC Data Access

Examples - OPC UA Complex Data

Examples - OPC UA Interaction