TimeSoFar can be > Value2*2
Well thats your problem right threre, Value2 is the length of a whole cycle, and when Timesofar is greater than that it is reduced to "LESS THAN VALUE2" in both mine and your method.
For TimesoFar to ever be > Value2*2 then DaltaTimesofar has to be greater than Value2. But Value two is the wavelength, so you are taking sample too infrequently.
Float(TimeSoFar)/Value2
This seems a bit pointless Timesofar is already a float. Maybe
TimeSoFar/Float (Value2)