Can Step through but when run defines variable wrong
Hi, thanks for helping
When I step through the following code (lots of junk removed so it
should be easier to read) it works fine, however when I run it it works
fine until i = 527 then I get an error, and TimetoPM's value is wrong.
It comes out negative even when the formula makes it positive?
For i = 1 To LoopNumber Step 1
Ttotal = 0
Tevent = 0
WeightedAge = 0
y = 1
x = 0
Do
If WeightedAge = 0 Then
Tf = Alpha * ((WeightedAge / Alpha) ^ Beta - Log(1 - Rnd))
^ (1 / Beta) - WeightedAge
TimeToPM = (Period * y - Ttotal)
If Tf < TimeToPM Then 'If (Time to fail) < (Time of next
SM - Time of Last Event)
'stuff in here but no defining of TimetoPM
Else
'more stuff but TimetoPM is not changed
WeightedAge = WeightedAge + TimeToPM * (1 -
RestoreFactor)
End If
y = y + 1 'update SM multiple counter for System
Time option
End If
Ttotal = Tevent + Tm
Else
x = 1
End If
Loop While x = 0
Next
|