Showing results 1 to 4 of 4

Thread: Get milliseconds information from CelItem

  1. #1
    ferran Gast

    Default Get milliseconds information from CelItem

    Hello all,

    Does anyone know how to get the milliseconds information from a CelItem object?

    I'm getting the user interaction to the "events list" through the "CelListSelectionChanged(ByVal obItem As ICelItem)" callback. It works fine. But I can't find any indication of the milliseconds value of the event appearance (you can get the CelItem.Time property that gives you a Date object, with seconds granularity)

    Thanks to everybody.

  2. #2
    Join Date

    Default Re: Get milliseconds information from CelItem


    VB does not support milliseconds when converting the Zenon timestamp, so you need to calculate them by yourself (from the Zenon double variable).

    you can use the following code:

    Private Sub zCEL_CelItemAdded(ByVal obItem As ICelItem)
        'when a new entry was generated....
        'Debug.Print "CelItemAdded - " & obItem.Text
         Dim zText As Variable
         Dim zTime As Variable  
         Dim myTime As Double
         Dim myTimeString As String
         Set zText = thisProject.Variables.Item("CEL_TEXT")
         Set zTime = thisProject.Variables.Item("CEL_TIME") 
         'get the ms
         myTime = obItem.Time
         myTime = myTime * 86400 * 1000
         myTimeString = CStr(myTime)
         myTimeString = Right(myTimeString, 3)
         zText.Value = CStr(obItem.Text)
         zTime.Value = CStr(obItem.Time) & "." & myTimeString           
    End Sub


  3. #3
    ferran Gast

    Default Re: Get milliseconds information from CelItem

    Thank you very much bernhardf, it works.

  4. #4
    ferran Gast

    Default Re: Get milliseconds information from CelItem

    If anybody else founds this Thread interesting, one last comment:

    It seems that the automatic conversion to VBA Date type rounds up the seconds if milliseconds > 500ms: If the date is, say, "2011/1/1 12:23:45.678", then the date when you call "obItem.Time" will return "2011/1/1 12:23:46".

    I used the following code to substract one second when ms >= 500ms:

    Private Sub zCEL_CelListSelectionChanged(ByVal obItem As ICelItem)
        Dim itemDate As Date
        Dim milliseconds As Integer
        ' Get the ms
        milliseconds = Int(Right(CStr(obItem.Time * 86400 * 1000), 3))
        ' Calculate seconds (avoid roundup)
        itemDate = obItem.Time
        If milliseconds >= 500 Then ' seconds have been roundup by VBA...
            itemDate = DateAdd("s", -1, itemDate) ' substract one second
        End If
    end sub

    Hope it helps somebody else.

Similar Threads

  1. Archives (RT) - Read batch information
    By herberto in forum VBA
    Replies: 4
    Last Post: 25th July 2011, 14:09
  2. CEL Entries in Milliseconds
    By shikra in forum zenon Energy Edition
    Replies: 2
    Last Post: 7th April 2010, 08:49
  3. Replies: 0
    Last Post: 11th March 2010, 16:04
  4. Information Unlimited 16 - Sample
    By robertf in forum VBA
    Replies: 0
    Last Post: 28th November 2008, 13:34
  5. We need further information about web server on zenOn...
    By nuno_duarte in forum zenon Network
    Replies: 4
    Last Post: 18th March 2008, 18:05

Posting Rules

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