Dim distance As Long = 999999999999
Dim index As Int = -1
For i = 0 To clv.GetSize - 1
Dim eventTime As Long = clv.GetValue(i)
Dim d As Long = Abs(DateTime.Now - eventTime)
If d < distance Then
distance = d
index = i
End If
Next
'The index variable holds the index of the closest item