Hi robertf,
thank you for your reply.
I think i know what the problem is. Vairables time1,time2 and time3 are Internal TIME variables in Zenon, and i can't "see" them as TIME variables in VBA, i "see" them as integers.
What i want to do is the following:
I have two times to be defined by the user: time1 (start time) and time2 (endtime). Every time the system time is between this interval, a bit should be ON.
startime = 13:30
endtime = 15:00
if system_time > startime and system_time< endtime then
...
Public Sub LeftClickDown_teste(obElem As Element)
Dim mytime1 As Variable
Dim mytime2 As Variable
'Dim mytime3 As Variable
Dim state As Variable
Dim now_time_str As string
Dim mytime1_str as String
Dim mytime2_str as String
Set mytime1 = thisProject.Variables.Item("time1")
Set mytime2 = thisProject.Variables.Item("time2")
Set mytime3 = thisProject.Variables.Item("time3")
Set state = thisProject.Variables.Item("timestate")
'actual time
now_time_str = (Format(Now, "hh:mm"))
' i tryed to convert all the values to strings..
mytime1_str = CStr(mytime1.Value)
mytime2_str = CStr(mytime2.Value)
'and then compare it like TimeValues.. the problem is that mytime.value is not in TIME format, it looks like an integer
If TimeValue(now_time_str) < TimeValue(mytime2_str) And TimeValue(now_time_str) > TimeValue(mytime1_str) Then
state.Value = "1"
MsgBox ("TRUE") ' for debugging
Else
'MsgBox ("FALSE")
state.Value = "0"
End If
End Sub
Thanks in advance!
Best regards,