For the code below, there is a form in which I take the values of start, end, and intervals (such as maintenance, training, or simplesmenet, interval).

If a user enters at the start: 23h10min00s: vector "start"will store "23" in "start (0)", "10 " in "start (1)" and "0" in "start (0)" and so also for the other vectors.

However, if a user type "20h15min10s" in the "beginning" and the "end" type "2h00min00s" (this is only possible if there another day), then the routine checks "end <start" and gives a Boolean value for the "midnight" and follow the code:

Code:
If midnight = False Then 'if there was no change of days, then proceeded by calculating normal
Total_time_in_seconds = (3600 *end(0).Value + 60 * termino(1).Value + termino(2).Value) - (3600 * start(0).Value + 60 * inicio(1).Value + inicio(2).Value) - (3600 * interval(0).Value + 60 * interval(1).Value + interval(2).Value) - (3600 * maintenance(0).Value + 60 * maintenance(1).Value + maintenance(2).Value) - (3600 * training
(0).Value + 60 * training(1).Value + training(2).Value)

Else 'but if there was a change of days, then the total time in seconds is given by another formula:

'tells how many seconds the machine work:
FirstDay = 3600 * 24 - (3600 * beginning (0) + 60 * start (1) + start (2)) 'on first day
SecondDay = (3600 * finish (0) + 60 * end (1) + end (2)) 'and the second day

    
'sum over time, in seconds, the machine worked on the second day, and finally subtract the time of intervals
   Total_time_in_seconds = FirstDay + SecondDay - (3600 * interval(0).Value + 60 * interval(1).Value + interval(2).Value) - (3600 * maintenance(0).Value + 60 * maintenance(1).Value + maintenance(2).Value) - (3600 * training
(0).Value + 60 * training(1).Value + training(2).Value)
What's wrong?