Dear all,
I have a table with three fields FR (Field Type Double Scientific), Time (Field type long integer general), Quantity (Field Type long integer general).
Now i have made a form which has all the fields of the table bound to it. in this form i have made a button called calculate.
what i want is .......
when i enter the FR and Time values and click the calculate button it should display the x value in the quantity field on the form. the formula is
summation (from x=1 to n)[ (FR*Time)x * (e(-FR*time))/ x!] >= 0.9
(sigma function)
basically, the code should return the value of x the moment expression value goes above 0.9.
the code i have used is as follows:
Private Sub Command7_Click()
Dim Prob As Double
Dim x, fact As Long
x = 1
fact = 1
For i = 1 To x
fact = fact * i
Next i
Prob = ((Me.FR * Me.Time) ^ x) * Exp(-(Me.FR * Me.Time)) / fact
Do While Prob < 0.9
x = x + 1
For i = 1 To x
fact = fact * i
Next i
Prob = Prob + ((Me.FR * Me.Time) ^ x) * Exp(-(Me.FR * Me.Time)) / fact
Loop
Me.Quantity = x
End Sub
I am getting an error in the bold underlined line of the code as overflow.
Can anyone help. this is really very urgent and important.
thanks