Re: Overflow 6 in code - why, and how to solve?
I see your point.. If I add a small value to T the code runs, but then I have constant values - and seems wrong too ... hmm.. But thank you
Re: Overflow 6 in code - why, and how to solve?
I see your point.. If I add a small value to T the code runs, but then I have constant values - and seems wrong too ... hmm.. But thank you
Re: Overflow 6 in code - why, and how to solve?
... I think the error is in my function y, because when I try debugging, the overflow statement is in this function, but I still cannot see what is wrong? If anyone could please help me
Re: Overflow 6 in code - why, and how to solve?
Oh, thanks
Dear everyone. I have coded the following, but I cannot get it to run...I get the errormessage "runtime error 6: overflow". Can anyone help me figure out how to make it work. This is my code:
'Opgave 2
Function Bkappa(Kappa As Double, Tau As Double) As Double
Bkappa = 1 / Kappa * (1 - Exp(-Kappa * Tau))
End Function
Function B1(Kappa As Double, Tau As Double) As Double
B1 = Bkappa(Kappa, Tau)
End Function
Function B2(Kr As Double, Ke As Double, Tau As Double) As Double
B2 = 1 / (Kr - Ke) * (Bkappa(Ke, Tau) - Bkappa(Kr, Tau))
End Function
Function A(Phi As Double, Kr As Double, Ke As Double, Br As Double, Be As Double, Rho As Double, Tau As Double)
A = (Phi / Kr) * (Tau - Bkappa(Kr, Tau)) _
- (1 / (2 * Kr ^ 2)) * (Br ^ 2 - ((2 * Rho * Br * Be) / (Kr - Ke)) + ((Be ^ 2) / (Kr - Ke) ^ 2)) * (Tau - Bkappa(Kr, Tau) - ((Kr / 2) * Bkappa(Kr, Tau) ^ 2)) _
- (1 / 2) * (Be ^ 2 / (Ke ^ 2 * (Kr - Ke) ^ 2)) * (Tau - Bkappa(Ke, Tau) - (Ke / 2) * Bkappa(Ke, Tau) ^ 2) _
+ (1 / (Kr * Ke * (Kr - Ke))) * ((Be ^ 2 / (Kr - Ke)) - (Rho * Br * Be)) * (Tau - Bkappa(Kr, Tau) - Bkappa(Ke, Tau) + Bkappa(Kr + Ke, Tau))
End Function
Function y(Phi As Double, Kr As Double, Ke As Double, Br As Double, Be As Double, Rho As Double, r As Double, E As Double, Tau As Double)
y = (A(Phi, Kr, Ke, Br, Be, Rho, Tau) / Tau) + (B1(Kr, Tau) / Tau) * r + ((B2(Kr, Ke, Tau)) / Tau) * E
End Function
Sub Problem2()
Dim Phi As Double
Dim Kr As Double
Dim Ke As Double
Dim Br As Double
Dim Be As Double
Dim Rho As Double
Dim i As Integer
Dim y1 As Double
Dim e1 As Double
Dim T As Double
Dim rr As Double
Dim ee As Double
Phi = 0.0225
Kr = 0.36
Ke = 0.1
Br = 0.03
Be = 0.02
Rho = 0
'For E=0
e1 = 0
For j = 0 To 5
rr = Cells(6 + j, 2).Value
For i = 0 To 20
T = Cells(5, i + 3).Value
y1 = y(Phi, Kr, Ke, Br, Be, Rho, rr, e1, T)
Cells(6 + j, i + 3) = y1
Next
Next
End Sub
Display More
Best regards,
Maria Wieborg