444,120 Members | 1,786 Online Need help? Post your question and get tips & solutions from a community of 444,120 IT Pros & Developers. It's quick & easy.

# Overflow Error

 P: 13 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 Replies

 Expert 100+ P: 1,295 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

 P: 13 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.03362289933 : Double pIn.H : 1488.14368430425 : Double pOut.H : 1292.74450695371 : Double which if you do the calculations: numer : 195.399177350541 : Double denom : 257.110061404928 : 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.759982617104987 : 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

 Expert 100+ P: 1,295 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.03362289933 : Double pIn.H : 1488.14368430425 : Double pOut.H : 1292.74450695371 : Double which if you do the calculations: numer : 195.399177350541 : Double denom : 257.110061404928 : 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.759982617104987 : 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.14368430425, 1292.74450695371, 1231.03362289933) it actually returned 0.759982617105007 (wich is preety close from the one you was expecting). I hope you find the solution soon. Hasta luego. Kad Jun 1 '07 #4 