Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    17

    Unanswered: Difficult problem with VB and OPC

    I am connecting to an OPC Server using VB. I can connect with the server ok. I have set up a browser that lets me select the tags I wish to view but I get Runtime Error 424, when I try to read the values.

    result = OPCItem.Read([Tagname], [Value], [state], 0)

    Tagname is a Variant
    Value is a Variant
    State is a Variant

    I looked in the object library and Im sure .Read() is the function I need
    however when I hold the mouse over the statement it tells me
    result = Empty
    [Value] = Empty

    Can anyone suggest why this isn't working or perhaps a better function to let me read the tags.

    Thanks
    Gerard

  2. #2
    Join Date
    Aug 2004
    Posts
    1
    Gerard

    According to OPC DA Automation Specs

    Syntax is:

    Read (Source As Integer, Optional ByRef Value as Variant, Optional ByRef Quality as Variant, Optional ByRef TimeStamp as Variant)

    Example they give

    Dim AnOPCItem as OPCItem
    Set OPCItem=GetOPCItem(SomeItemServerHandle)
    Dim Source as Integer
    Dim Value as Variant
    Dim Quality as Variant
    Dim TimeStamp as Variant
    Source=OPC_DS_DEVICE
    AnOPCItem.Read Source,ServerHandles,Value,Quality,TimeStamp
    'process the values
    TextBox.Text=Value

    Hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •