Showing results 1 to 2 of 2

Thread: determining the name of the variable to trigger the function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    13.02.2020
    Posts
    1

    Default determining the name of the variable to trigger the function

    Hello together,

    I would like to know how I can access the name of a variable that caused a function to be started. I have got several boolean variables (import-variables from some sensors) that can either be true of false. I also created internal variables to count how long these sensors are sending a "true"-signal. When they turn "false" again I want to reset that counter. My problem is that I don't know how to archieve that. All these variables refer to one single matrix. So inside that reaction-matrix I want to link a function for the case that the variable turns "false". I dont want to create one matrix for each variable because there are way too many. My idea was to create a function via vba that automatically determines the name of the variable that triggerd the matrix. Then I could use that name to change the value of the related count-variables (which have similar names). Can somebody here please help me with that?

    Public Sub reset_count(obElem As Element)
    Dim countVar As Variable
    Dim sensorVar As Variable

    '[...Code...]

    Set countVar = thisProject.Variables.Item("[...Name from the Code...]")
    Debug.Print countVar.Value
    countVar.Value = 0
    End Sub

    Best regards
    Leon
    Last edited by Leon : 13th February 2020 at 14:48

Similar Threads

  1. trigger the Screen type action by variable
    By sgh66 in forum zenon Supervisor
    Replies: 1
    Last Post: 8th November 2019, 11:10
  2. Replies: 3
    Last Post: 23rd October 2013, 22:21
  3. Execute a Function on changes of a Float Variable
    By mcavdar in forum zenon Supervisor
    Replies: 2
    Last Post: 9th January 2013, 13:43
  4. How to trigger a function when a variable changed?
    By denver in forum zenon Supervisor
    Replies: 1
    Last Post: 16th May 2012, 10:12
  5. Replies: 3
    Last Post: 5th April 2011, 09:16

Tags for this Thread

Posting Rules

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