Home Features
& Benefits What Is OPC Free Demo Purchasing Sample Code 
 & Support

Additional Tutorials and Example Code

On this page we post additional tutorials and sample code that we have created to address specific ways of using the OPC Data ActiveX control or specific application needs. 

Many of these samples assume that you have our TOP Server OPC server already installed on your machine if you want to run them without modification. Those programs that use our TOP Server will use the "simdemo" project that comes with the server and are clearly commented if you want to modify them to use with your OPC server of choice.  You may download a free demo of our TOP Server if you wish at any time.

Optional: Download ALL the examples on this page in one zip file (460 Kb). AllSampleCode.zip

Item

Devel. Lang.

Description

Download/View

1

VB.NET

Using the OPC Data ActiveX control with Visual Basic.Net

View Tutorial

2

VB.NET

Read Array Tags using VB.NET 2003 - This example shows you how to use the ReadVariable method to read Tags of type Array. This sample shows you how to detect if a tag is an array, and then how to detect if it is a 2-dimensional array. All output is to a listview control. All code is fully commented.

Download Code

3

VB6

Simple read without writing any code.  Tutorial that shows the simple no code procedure to do OPC Data Binding with the OPC Data ActiveX control. Also available is a sample program that works with our TOP server running in simulation mode. (see example 3)

View Tutorial

 

4

VB6

Simple write - expands on the simple read by adding a very simple procedure to write data to the OPC server. If you'd like you can download the completed VB program for simple read and write. This sample works with the simulation OPC server that is installed with the OPC Data ActiveX software (demo or licensed).

View Tutorial

Download Code

5

VB6

How to use the ReadVariable method - shows how to programmatically write a single data item - for the OPC experts among our readers, this example uses the IOPCSyncIO::Read() method with source=Device.

Download Code

6

VB6

How to use the WriteVariable method - shows how to programmatically write a single data item - for the OPC experts among our readers, this example uses the IOPCSyncIO::Write() method.

Download Code

7

VB6

How to use the ReadMultiVariable method - same as ReadVariable but uses this method that lets you read multiple OPC items from a single OPC server in a single method call. For the OPC experts among our readers, this example uses the IOPCSyncIO::Read() method with source=Device and passes in multiple item handles in a single call.

Download Code

8

VB6

How to use the WriteMultiVariable method - same as WriteVariable but uses this method to write multiple OPC items to a single OPC server in a single method call. For the OPC experts among our readers, this example uses the IOPCSyncIO::Write() method and passes in multiple item handles and values in a single call.

Download Code

9

VB6

How to use the server browser object to browse for available OPC Servers on a computer - do you have an application where you want to let users browse for available OPC servers? The OPC Data control includes a powerful object for doing so.  This example shows how to use it.

Download Code

10

VB6

How to use the item browser object to browse for available OPC items on a selected OPC server - this example browses our TOP Server OPC Server running the simdemo project. It is easily modified to work with any OPC server that supports Item browsing.

Download Code

11

VB6

How to Browse Servers and Tags - this example integrates things you learn from the above two examples into a single project.

Download Code

12

VB6 & VC++

How to programmatically connect at runtime objects to tags for Reads - this example programmatically at runtime connects visible objects on the screen (i.e. a label) to an OPC item that the user picks through browse dialogs.

Download Code (VB6)

Download Code (VC++)
(please be sure to review the Connect_Object_README.txt file included i this zip file)

13

VB6

How to programmatically connect at runtime objects to Tags for writes - this example builds upon the previous example and shows how data typed into a bound text box will automatically be written to the OPC server.

Download Code

14

VB6 & VC++

How to programmatically setup subscription reads without having to bind to visible items. This is a very powerful example that shows how you can write a program using the OPC Data control with all reads done programmatically.  It shows how to capture data returned by your OPC server in the OPC Data control's ValueChanged event as well as how to setup the subscription.  We have 2 examples of this popular type of connection for VB and one for VC++.

Download Code - VB Example 1

Download Code - VB Example 2

Download Code - VC++ (please be sure to review the Connect_Object_README.txt file included i this zip file)

15

VB6

How to read Tag Arrays - some OPC Servers support an array data type for OPC items. This example shows how to read these item types using the OPC Data Control. Examples are available using the ReadVariable method as well as through subscription reads.

Download Code (ReadVariable version)

Download Code (Subscriptions version)

16

VB6

How to write to Tag Arrays - this example complements the one above and shows how to write array tags if your OPC server supports it.  This example uses the WriteMultiVariables method.

Download Code

17

VB6

Using the OPC Data Control with RS Linx - reading multiple items - This basic sample shows you how to read multiple items from RSLinx programmatically, either synchronously or via subscription reads.

Download Code

18

VB6

Using the OPC Data Control with RS Linx - reading array items (i.e. [PLC5_40]N7:0,L5 ) using either ReadVariable or Subscription reads.

Download Code

19

VB6

Using the OPC Data Control with RS Linx - reading single items and array items in a single ReadMultiVariables method call - this example takes the ReadMultiVariables method to its full extent.  The concepts applied here can also be used with subscription reads.

Download Code

20

VB6 & VC++

Free OPC Server Browser and Item Browser Tutorial & Sample Code - see how the sample Item Browser program included with the product works. Download sample code in VB or VC++ for using the OPC Server & Item Browser objects. (Note - although the VB sample is included with the product demo installation, this download is an updated version)

View Tutorial

VB Sample Code
VC++ Sample Code

21

VB6

Read/Write using ReadVariables, ReadMultiVariables, WriteVariables, WriteMultiVariables Methods - This example is for the user who wishes to programmatically interface with the ActiveX and shows how to do synchronous reads/writes of multiple variables at ONE time using Visual Basic code and the ReadMultiVariables and WriteMultiVariables methods.

View Tutorial

VB Sample Code

22

Delphi

Browse Demo - this example replicates our Browse Demo application that comes with the OPC Data ActiveX in Delphi.

Download Code (Delphi)

23

VB.NET

Dynamically Instantiating the OPC Data Control - this example shows how to do a simple instantiation of the control in VB.NET

Download Code

Copyright Software Toolbox, Inc., 1996-2002, All Rights Reserved Worldwide.
148A East Charles Street, Matthews, North Carolina, USA 28105
Phone: 704-849-2773 or 1-888-665-3678 (US), Fax: 704-849-6388
Business hours - Monday to Friday, 8 AM to 5 PM EST (GMT-5)