Showing results 1 to 6 of 6

Thread: Get a variable value

  1. #1
    nblanquart Gast

    Default Get a variable value

    Hello,

    I would like to get the value of a variable, but ZenOn throws me an "Undefined" error.
    That is the code I implemented at this moment.

    Dim Temp As variable
    Temp = thisProject.Variables.Item("time_temp").Value()

    Thanks for helping.

  2. #2
    Join Date
    28.07.2008
    Posts
    64

    Default Re: Get a variable value

    This should be work. Be sure that your string is correct-> case sencetive!

    Dim Temp As variable
    Temp = thisProject.Variables.Item("time_temp").Value

  3. #3
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: Get a variable value

    check out this thread regarding reading of variable values via VBA:
    http://www.copadata.com/forums/showp...2&postcount=12

    Regards,
    Herbert

  4. #4
    nblanquart Gast

    Default Re: Get a variable value

    Thanks for your answers

  5. #5
    nblanquart Gast

    Default Re: Get a variable value

    Okay.. So I have an other problem. I try to put a value in a variable but it always shows me a "0" in the ZenOn Runtime.

    That's my code:
    Sub archiveSetTime()
        
        thisProject.Variables.Item("test_archive_timer").Value = Now
    
    End Sub

    Thanks

  6. #6
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: Get a variable value

    The Now() functions returns the current date/time in form of the data type Variant (Date)
    -> which datatype does the variable "test_archive_timer" have?

    Declare your variable as String and it should work then.

    Note: there exists also a zenon function which writes the current date/time to a variable
    -> see function at the category "Variable" -> Write time to variable
    "With this function a connected PLC can be synchronized with the PC. When executing this function, the System time is taken and saved in a String varialbe of the format: DD.MM.YYYY HH:MM:SS"


    Regards,
    Herbert

Posting Rules

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