Count all Alarms for a Specific Tag

This example counts all the alarms for a specific tag through the use of a while loop.

Example Code

count = 0
Set AlarmObj = PreviousAlarmForTag("Simulation00001", "Simulated", 
"Now 1Second") While Not(AlarmObj Is Nothing)
  count = count + 1
  Set AlarmObj = PreviousAlarmForTag(AlarmObj.Tag, AlarmObj.ConditionName, DateAdd("s", -1, AlarmObj.StartTime)) Wend

result = count