473,715 Members | 2,133 Online

# Overflow Error

13 New Member
Ok, I've been working on this for two days and have finally resulted to asking for help. I am designing a program for my work that will emulate the thermodynamic systems of a power plant. however, I have a very simple issue that I cannot seem to fix... here is the code snippet:

Property Get Eff() As Double 'Efficiency of the Turbine
If pType = HP Then
Dim I As Integer
Dim OutEnth As Double 'Enthalpy
Dim OutIEnth As Double 'Isentropic Enthalpy
Dim out As Double
OutEnth = pOut.H
OutIEnth = STMPSH(pOut.P, pIn.S)
For I = 1 To pExts.Count
OutEnth = OutEnth + pExts(I).H
OutIEnth = OutIEnth + STMPSH(pExts(I) .P, pExts(I).S)
Next I
Dim numer As Double
Dim denom As Double

numer = pIn.H - pOut.H
denom = pIn.H - STMPSH(pOut.P, pIn.S)
out = numer / denom

Eff = out '(numer / denom) '(pIn.H - pOut.H) / (pIn.H - STMPSH(pOut.P, pIn.S)) * 100
ElseIf pType = LP Then
Eff = (pIn.H - ELEP) / (pIn.H - STMPSH(pIn.P, pOut.S)) * 100
ElseIf pType = IP Then
Eff = (pIn.H - pOut.H) / (pIn.H - STMPSH(pOut.P, pIn.S)) * 100
End If
End Property

the underlined portion is where I get an overflow error. I'm not sure why either. If you step through it using the debugger, it works just fine (which I really don't think the users of this program want to use the Step Into function to run this whole thing). but if you run the code, it spits out runtime error 6, overflow. I've used a calculator and the numbers work. The variable Out doesn't spit an error, but the return of Eff does. same data type too. I need some help. thanks...
May 31 '07 #1
3 2244
1,295 Recognized Expert Top Contributor
Hi!!

So you say you're not having any trobule giving some value to "out" so, why dont you try giving "eff" the same variable type than "out" (i'd guess its a double or a string).

I dont know very much about thermodinamic, so why dont you give us some values for the inputs so we can check'm

Good Luck
May 31 '07 #2
Tophurious
13 New Member
out is defined as a Double, as with Eff (the function return value).

lets see the values would be:
STMPSH(pOut.P, pIn.S) returns 1231.0336228993 3 : Double
pIn.H : 1488.1436843042 5 : Double
pOut.H : 1292.7445069537 1 : Double

which if you do the calculations:
numer : 195.39917735054 1 : Double
denom : 257.11006140492 8 : Double
these two were used just to see if either the numerator of the Eff or denominator of the Eff calc were causing the overflow.
out : 0.7599826171049 87 : Double

like I said, if I use F8 in the debugger to step through the code, I get no errors, no problems, everything all hunky-dory. However! If I just run the code, I get the nice "Run Time Error '6': OverFlow!"... so first off why is it only when I run the code, it should also spit the exception when I am steping through, and second.... why is it spitting the exception at all. the numbers are right and the equate out to the ~76% that out is....
May 31 '07 #3
1,295 Recognized Expert Top Contributor
out is defined as a Double, as with Eff (the function return value).

lets see the values would be:
STMPSH(pOut.P, pIn.S) returns 1231.0336228993 3 : Double
pIn.H : 1488.1436843042 5 : Double
pOut.H : 1292.7445069537 1 : Double

which if you do the calculations:
numer : 195.39917735054 1 : Double
denom : 257.11006140492 8 : Double
these two were used just to see if either the numerator of the Eff or denominator of the Eff calc were causing the overflow.
out : 0.7599826171049 87 : Double

like I said, if I use F8 in the debugger to step through the code, I get no errors, no problems, everything all hunky-dory. However! If I just run the code, I get the nice "Run Time Error '6': OverFlow!"... so first off why is it only when I run the code, it should also spit the exception when I am steping through, and second.... why is it spitting the exception at all. the numbers are right and the equate out to the ~76% that out is....
Hi, i realy dont know where the error could be. I tried making a function and it worked perfectly, i think you should see if the problem is inside or outside this method. (or just delete de eff=out line and rename the prop as "Out" jajajajaja)

By the way, here's the function i made:

Public Function Eff(pInH As Double, pOutH As Double, STMP As Double) As Double 'Efficiency of the Turbine

Dim out As Double
Dim numer As Double
Dim denom As Double

numer = pInH - pOutH
denom = pInH - STMP
out = numer / denom

Eff = out '(numer / denom) '(pIn.H - pOut.H) / (pIn.H - STMPSH(pOut.P, pIn.S)) * 100
End Function

and when i tried
Eff(1488.143684 30425, 1292.7445069537 1, 1231.0336228993 3)
it actually returned 0.7599826171050 07 (wich is preety close from the one you was expecting).

I hope you find the solution soon.

Hasta luego.