QuickOPC in Visual Basic (VB.NET)
QuickOPC makes it easy for you to integrate OPC client functionality into your Visual Basic.NET solution (VB6 users click here), or create OPC VB.NET solutions from scratch. Reading a value from OPC Data Access or OPC Unified Architecture server, or writing a data value can be achieved in just one or two lines of code. You can also set up subscriptions and receive event notifications about data changes.
Component interfaces hide the complexities of OPC, and are designed specifically with .NET and Visual Basic.NET developer in mind, making you feel right at home when referencing and using them.
The components can be used from various environments: Windows Forms, ASP.NET pages, console applications, Windows services, and WPF applications are all supported. The development tool we have targeted primarily is Visual Studio.
- QuickOPC also supports OPC UA Alarms&Conditions.
For OPC server development in VB.NET, see OPC Wizard instead.
Read MoreSimple OPC UA Visual Basic (VB.NET) Example
The code below (in Visual Basic language) reads and displays a monitored item value, using QuickOPC.NET:
' Obtain value of a node and display it in a message box
MessageBox.Show(EasyUAClient.SharedInstance.ReadValue(
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853"))
The code below subscribes to changes of a monitored item value, and displays the value with each change:
' The callback is a lambda expression that displays the value
EasyUAClient.SharedInstance.SubscribeDataChange(
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853", 1000,
Sub(sender, args) Console.WriteLine(args.AttributeData.Value))
OPC UA PubSub
The PubSub variety of OPC UA (as opposed to client-server) uses message-oriented middleware to deliver the data. QuickOPC supports it as well, as shown in the example below.
' The callback displays information about the dataset message received.
EasyUASubscriber.SharedInstance.SubscribeDataSet(
"opc.udp://239.0.0.1",
Sub(sender, args) Console.WriteLine(args.DataSetData))
OPC Data Access ("Classic")
The code below reads and displays an item value:
' Read item value and display it in a message box
MessageBox.Show(EasyDAClient.SharedInstance.ReadItemValue(
"", "OPCLabs.KitServer.2", "Demo.Single"))
This is how you can subscribe to changes of an item, and display the value with each change:
' The callback is a lambda expression that displays the value
EasyDAClient.SharedInstance.SubscribeItem(
"", "OPCLabs.KitServer.2", "Demo.Single", 1000,
Sub(sender, args) Console.WriteLine(args.Vtq.Value))
No other product can do this in such a clear and concise code, in a single statement!
Useful links: VB.NET Examples / VB.NET in Knowledge Base / VB.NET examples GitHub repository
Footnote & required disclosure: QuickOPC (including its Options) is a software development kit (SDK) for development of OPC clients and subscribers. Installing QuickOPC or its Options does not change system settings.