OPC Alarms and Events Client

Posted on 2004-11-23
Last Modified: 2012-08-13

 For a VB application I would like to have a connection to an OPC Alarms & Events server. Does anyone have a code example to create a connection and catch the events from an OPC AE server?
 I've tried it out for myself but I keep getting stuck (VB crashes) when I create an OPCEventSubscription

 This is the code I created so far:

Option Explicit

Private opcAEServer As OPCEventServer
Private opcAESubscripts As OPCEventSubscriptions
Private opcAESubscript As OPCEventSubscription

Private varServers As Variant

Private Sub cmdConnect_Click()
On Error GoTo ErrorHandler

Set opcAEServer = New OPCEventServer
varServers = opcAEServer.GetOPCServers

opcAEServer.Connect varServers(0)

If opcAEServer.ServerState <> OPCServerState.OPCRunning Then
    MsgBox "OPC AE server is not running"
    Set opcAEServer = Nothing
    Exit Sub
End If

Set opcAESubscripts = opcAEServer.OPCEventSubscriptions
opcAESubscripts.DefaultBufferTime = 0
opcAESubscripts.DefaultMaxSize = 0
opcAESubscripts.DefaultIsActive = True

'Set opcAESubscript = opcAESubscripts.Add("TestApp")

Exit Sub
MsgBox "Error Connecting to OPC AE : " & Err.Number & " " & Err.Description
End Sub

Private Sub cmdDisconnect_Click()
    Set opcAESubscript = Nothing
    Set opcAESubscripts = Nothing
    Set opcAEServer = Nothing
End Sub
Question by:TrackMax
    LVL 10

    Accepted Solution


    Author Comment


    I have got this information already, however it does not contain any examples of the usage of the OPC AE control. It gave up looking for it, so I'll close this topic.

    Best regards,


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension ( This reminded me of questions tha…
    This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
    The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
    XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now