Showing results 1 to 2 of 2

Thread: How to change? VBA code -> c# code

  1. #1
    Join Date
    23.02.2016
    Posts
    28

    Default How to change? VBA code -> c# code

    VBA Sample code
    but You don't know what this is clsTimeConvert
    C # How can I use?
    VBA code to C # code i want to change.

    Sub zenOn_ArchiveFilter()
    'Declarations
    Dim zArchive As Archive
    Dim zArvFilter As ArchiveFilter
    Dim zArvVars As ArchiveFilterVariables
    Dim zTimeConvert As clsTimeConvert
    Dim dTime As Double
    Dim i As Integer

    'Initialize zArchive with the first available archive
    Set zArchive = thisProject.Archives.Item(0)

    'If no archive is availabe, then ...
    If zArchive Is Nothing Then
    '... inform the user
    MsgBox ("No archive available!")

    Else
    'Initialize zArvFilter by creating a new archive filter
    Set zArvFilter = zArchive.ArchiveFilters.CreateArchiveFilter

    'Every archive variable within the collection...
    For i = 0 To zArchive.ArchiveVariables.Count - 1
    '... will be added to the archive filter
    zArvFilter.AddArchiveVariable zArchive.ArchiveVariables.Item(i)
    Next i

    'Initialize zTimeConvert by creating a new instance of the zenOn "clsTimeConvert" macro
    Set zTimeConvert = New clsTimeConvert

    'Set dTime by converting the desired system time into the zenOn compatible UTC time
    dTime = zTimeConvert.System2zenOn(CDbl(CDate("30.07.2007 14:00:00")))
    'Set the converted time as the start time for the filter
    zArvFilter.StartTime = dTime

    'Set dTime by converting the desired system time into the zenOn compatible UTC time
    dTime = zTimeConvert.System2zenOn(CDbl(CDate("31.07.2007 11:15:00")))
    'Set the converted time as the end time for the filter
    zArvFilter.EndTime = dTime

    'All I-BIT and HWERT bits
    zArvFilter.StatusMask = &H41000 'Check only I-BIT + HWERT
    zArvFilter.StatusBit = &H41000 'Return data if one of those bits are TRUE or both

    'Initialize zArvVars by initiating a new filter query
    Set zArvVars = zArvFilter.Query

    'For every filtered variable within the result...
    For i = 0 To zArvVars.Count - 1
    With zArvVars.Item(i)
    '... output the name of the variable ...
    Debug.Print "Variable: " & .ArchiveVariable.Name
    '... and the amount of I-BIT and HWERT bits within the specified time range
    Debug.Print vbTab & "I-BIT + HWERT: " & .ArchiveValues.Count & vbNewLine
    End With
    Next i
    End If
    End Sub

  2. #2
    Join Date
    23.02.2016
    Posts
    28

    Default Re: How to change? VBA code -> c# code

    solved!

Similar Threads

  1. Replies: 3
    Last Post: 21st June 2017, 11:05
  2. Using C++ code in Zenon
    By mrocznia in forum VSTA
    Replies: 2
    Last Post: 22nd January 2014, 14:42
  3. Replies: 6
    Last Post: 19th August 2013, 00:15
  4. Replies: 4
    Last Post: 22nd February 2012, 20:42

Posting Rules

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