Showing results 1 to 5 of 5

Thread: Help with OnlineVariables in VBA

  1. #1
    loop Gast

    Unglücklich Help with OnlineVariables in VBA

    Hello

    I am using VipWin 6.01 softver for my SCADA project and i am trying to create OnlineVariables in VBA for this project. My variables are Boolean, and i have 6 variables i want to track from VipWin to VBA. I try everything, including this code http://www.copadata.com/forums/showthread.php?t=41
    I always get run-time error"-214717848"80010108) Method 'CreateOnlineVaribles' of object of 'IOnlinevaribles' failed...

    I need to know where to put my code for online variables and some good explanation how this staff works.

    Please help I am desperate!!!

    Thank you

  2. #2

    Default Re: Help with OnlineVariables in VBA

    Maybe you could give a short explanation of what you would like to do, after you recognize the value changes in VBA for these 6 variables?

    Please be aware that incorrectly implementing this could impact the stability of your runtime.

    I can definitely recommend attending a VBA integration training, to learn the basics for a correct implementation and where you need to be careful.

    For a start you need to put your code into the "ThisProject" section of your zenon project.
    You cannot execute it from within the editor. This code is running in the runtime.

  3. #3
    loop Gast

    Rotes Gesicht Re: Help with OnlineVariables in VBA

    Thank you, markclemens

    After I recognize the value changes in VBA for these 6 variables( 6 variables are sensors on asemblly line), i want to save data (name of element, position...) in my database, dependent which variable is active. And after that I want to search and display my position ( position of element on my assembly line) with VBA form search. My form for database and serch are working perfectly.
    But I need Online Varibles to decided when form database appears ( sensor active).

    I put my code into the "ThisProject", this is the code
    Dim WithEvents zOLV As OnlineVariable
    Const strOLV As String = "MyOnlineVariableContainer"

    'initialize event on runtime startup
    Private Sub Project_Active()
    'get object if already exists
    Set zOLV = thisProject.OnlineVariables.Item(strOLV)
    If zOLV Is Nothing Then
    'if not exitst, create a new OnlineVariable container
    Set zOLV = thisProject.OnlineVariables.CreateOnlineVariables( strOLV)
    'add variables to the container
    zOLV.Add "sensor1"
    zOLV.Add "sensor2"
    zOLV.Add "sensor3"
    zOLV.Add "sensor4"
    zOLV.Add "sensor5"
    zOLV.Add "sensor6"
    End If
    'activate 'VariableChange' event
    zOLV.Define
    End Sub

    'event is fired when a variable value changes
    Private Sub zOLV_VariableChange(ByVal obVar As IVariable)
    Dim vValue As Variant
    vValue = obVar.Value
    'ignore error values (i.e. on startup)
    If IsError(vValue) Then Exit Sub
    Debug.Print obVar.Name & " = " & vValue
    End Sub

    'release objects on closing the runtime
    Private Sub Project_Inactive()
    'deactivate 'VariableChange' event
    If Not zOLV Is Nothing Then zOLV.Undefine
    Set zOLV = Nothing
    End Sub

    But I still get Runtime Error 91 : Object Variable or with block variable not set ....
    Varibles in VipWin and in VBA are with same name and font, there are Boolean...
    Last edited by loop : 9th February 2011 at 01:01

  4. #4
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: Help with OnlineVariables in VBA

    When do you get this error?
    -> at starting / stopping runtime?
    -> when a value changes?

    This error appears if you want to access an created object which is not valid anymore (object = Nothing).

    Maybe this error is triggered from another code within your project. Simply comment out all other code within your VBA code a check if the error appears again.

    Regards,
    Herbert

  5. #5
    loop Gast

    Lächeln Re: Help with OnlineVariables in VBA

    Thank you, herberto

    Ithink i've found my error in meodul 1... And I Change The Code:
    Private Sub zOLV_VariableChange(ByVal obVar As IVariable)
    Dim vValue As Variant
    vValue = obVar.Value
    'ignore error values (i.e. on startup)
    If IsError(vValue) Then Exit Sub
    Debug.Print obVar.Name & " = " & vValue

    if obVar.Name=sensor1 and vValue=1 then
    frmdatabase.show
    else
    'msgbox()
    end if
    End Sub

    Everything Is Working Perfectly!!!
    Thank you people and sorry if my English is not perfect.

Similar Threads

  1. Replies: 5
    Last Post: 16th July 2009, 14:39
  2. Working with 'OnlineVariables'
    By robertf in forum VBA
    Replies: 1
    Last Post: 16th April 2008, 16:26

Posting Rules

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