COPC32/COPCDLL OPC Data on Event

In this article, I will show how to use OPC Data event to control something. For example, doing some operation if value of specified OPC Tag changed.

In COPCDLL, it is “datChange” event can be used to detect if specified OPC tags data changed or not.

The VS C# example  below shows if data of OPC tag which has index number 1 is changed, the code will write data value 111 to OPC tag has index number 2.


 Private Sub copc1_datChange(tagIndex As Integer) Handles copc1.datChange

            Select Case tagIndex
                Case 0

                Case 1
                    copc1.opcWrt(2, 111)

                Case 2

            End Select

        Catch ex As Exception

        End Try

    End Sub

In COPC32, it is event ‘datChngX’ can do the same operation.


The example below shows id (index numner) of OPC tag that it’s data is changed.

Private Sub Axcopc1_datChngX(sender As Object, e As AxCOPC32.__copc_datChngXEvent) Handles Axcopc1.datChngX
        Label1.Text =
    End Sub
This entry was posted in COPC. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s