473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Overflow Error

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 2230
kadghar
1,295 Expert 1GB
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
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
kadghar
1,295 Expert 1GB
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

Sign in to post your reply or Sign up for a free account.

Similar topics

44
by: JKop | last post by:
You know how the saying goes that *unsigned* overflow is... well.. defined. That means that if you add 1 to its maximum value, then you know exactly what value it will have afterward on all...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
4
by: Chua Wen Ching | last post by:
Thanks Derek... Okay i had another question.. my program runs smoothly for the first minute, after 1 minute... suddenly it breaks and display this error: do you know what is the cause of...
25
by: junky_fellow | last post by:
Is there any way by which the overflow during addition of two integers may be detected ? eg. suppose we have three unsigned integers, a ,b, c. we are doing a check like if ((a +b) > c) do...
8
by: starffly | last post by:
In my program, the caculated value is supposed to be no more than the constant named MAXINT,otherwise, overflow error will be informed.however, I cannot test if the value exceeds MAXINT within the...
10
by: Parachute | last post by:
Using Borland Builder 6, I get numerical overflow when running a small programme without CodeGuard ("exp: OVERFLOW error"). The programme does not give any error messages when CodeGuard is...
1
by: zaneh | last post by:
I have found TheScripts a very useful site, but however I cannot find an answer to a problem I am having, so I finally have to ask the question! I am getting an Overflow error in a Function I have...
3
by: MLH | last post by:
A wide comma delimited text file import into A97 failed with an overflow error. I'm estimating it to have been no more than 1000 records. 100% of all the fields were quoted strings or ZLS's. ...
3
by: jer006 | last post by:
Hi I am writing a select statement that has an arithmetic function inside a case statement that uses logic to decide whether to divide or multiply and when I run the arithmetic statements outside...
42
by: thomas.mertes | last post by:
Is it possible to use some C or compiler extension to catch integer overflow? The situation is as follows: I use C as target language for compiled Seed7 programs. For integer computions the C...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.