If sysevent.newVal Then
this.toggle = (Int((2) * Rnd + 1))
this.Random_Minute = (Int((this.MinuteRange) * Rnd + 1))
if this.toggle = 1 then
this.OutTime = This.InTime + (this.Random_Minute/24/60)
this.OutTime = This.InTime - (this.Random_Minute/24/60)
- toggle is an integer that is either the number 1 or 2. This determines if you add or substract the random time to your schedule time. If 1 it adds the random time and if 2 it subtracts the random time.
- random_minute is a number randomly generated. It ultimately is utilized to calculate a minute that is added or subtracted to your scheduled time.
- MinuteRange is the upper range or your random time in minutes. If you want your lights to come on at 7pm + or - (1 to 30 minutes) then enter in 30. Based on this figure your random minute can be anything between 1 and 30 minutes depending on what is generated from the random number generator.
- InTime is user defined as the originally scheduled time (lets say 7pm).
- OutTime is calculated by taking your InTime (7pm) and either subtracts or adds the random figure.
Im sure there are easier ways to do this but this was my stab and it seems to work. First VBscript I've written. I still dont understand the "this." part but it works ;-)