473,835 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Eerie problem with compiler... need help

13 New Member
So I posted this before, but got no answer. I found a way around it but now my backway is doing the same problem.

Basically, in one of my get methods:
Expand|Select|Wrap|Line Numbers
  1. Property Get H() As Double
  2.     H = CalcH 'This was implemented as the "Back Way" and it fixed problem, before the code in CalcH was in here
  3. End Property
  4.  
  5. Private Function CalcH() As Double
  6.     If pH <= 0# And pT > 0# And pP > 0# Then 'calculate if not set
  7.         pH = STMPTH(pP, pT)
  8.     ElseIf pH <= 0# And pT > 0# Then
  9.         If pType = StreamType.Water Then
  10.             pH = STMTQH(pT, 0#)
  11.         Else
  12.             pH = STMTQH(pT, 1#)
  13.         End If
  14.     ElseIf pH <= 0# And pP > 0# Then
  15.         If pType = StreamType.Water Then
  16.             pH = STMPQH(pP, 0#)
  17.         Else
  18.             pH = STMPQH(pP, 1#)
  19.         End If
  20.     End If
  21.     CalcH = pH
  22. End Function
  23.  
When I run the program, I give pH a value of 1488. But when it comes to retrieving that value the compiler goes nuts. If I run the program, I get "Error 6: Overflow". So I use the debugger, I step through the WHOLE program... and it completes its run with no issue.... so I run again... and get the error. I find out it is when I retrieve the H value. So I put a break right there. I run program to the break and then step through the retrieval and find something quite odd. When it gets to the
Expand|Select|Wrap|Line Numbers
  1. If pH <= 0# And pT > 0# And pP > 0# Then 'calculate if not set
it actually returns true... but pH has a value of 1488! so I do this again and mouse over the pH to see what it says and it says "pH = 0" thats odd... I hit F8 to step. then mouse over pH, still "pH = 0" I open up the locals window and locate the pH variable. it says "pH = 1488", I mouse over pH again and now it says "pH = 1488" BUT IT JUST PASSED AN IF STATEMENT SAYING IF<=0!!!! please help!

Screenshots (in order):
#1
#2
#3
#4
#5
#6
#7
Jun 21 '07 #1
7 1576
pureenhanoi
175 New Member
So I posted this before, but got no answer. I found a way around it but now my backway is doing the same problem.

Basically, in one of my get methods:
Expand|Select|Wrap|Line Numbers
  1. Property Get H() As Double
  2.     H = CalcH 'This was implemented as the "Back Way" and it fixed problem, before the code in CalcH was in here
  3. End Property
  4.  
  5. Private Function CalcH() As Double
  6.     If pH <= 0# And pT > 0# And pP > 0# Then 'calculate if not set
  7.         pH = STMPTH(pP, pT)
  8.     ElseIf pH <= 0# And pT > 0# Then
  9.         If pType = StreamType.Water Then
  10.             pH = STMTQH(pT, 0#)
  11.         Else
  12.             pH = STMTQH(pT, 1#)
  13.         End If
  14.     ElseIf pH <= 0# And pP > 0# Then
  15.         If pType = StreamType.Water Then
  16.             pH = STMPQH(pP, 0#)
  17.         Else
  18.             pH = STMPQH(pP, 1#)
  19.         End If
  20.     End If
  21.     CalcH = pH
  22. End Function
  23.  
When I run the program, I give pH a value of 1488. But when it comes to retrieving that value the compiler goes nuts. If I run the program, I get "Error 6: Overflow". So I use the debugger, I step through the WHOLE program... and it completes its run with no issue.... so I run again... and get the error. I find out it is when I retrieve the H value. So I put a break right there. I run program to the break and then step through the retrieval and find something quite odd. When it gets to the
Expand|Select|Wrap|Line Numbers
  1. If pH <= 0# And pT > 0# And pP > 0# Then 'calculate if not set
it actually returns true... but pH has a value of 1488! so I do this again and mouse over the pH to see what it says and it says "pH = 0" thats odd... I hit F8 to step. then mouse over pH, still "pH = 0" I open up the locals window and locate the pH variable. it says "pH = 1488", I mouse over pH again and now it says "pH = 1488" BUT IT JUST PASSED AN IF STATEMENT SAYING IF<=0!!!! please help!
i saw that you are programing about Class. I've never seen this type of error before. But i think problem here is caused by Local Varriables and Global Varriables. Can u discribe more about ur Class. ( Member Varriables and Member Function)
Jun 22 '07 #2
Killer42
8,435 Recognized Expert Expert
I can't look at the images right now, because my work system blocks them. Will have a look in a few hours when I'm at home. In the meantime...

Are you setting it to 1488 or 1488# ? Perhaps there's an unintended conversion happening somewhere along the line, which is causing a calculation to overflow. VB, along with some other languagesw, has a nasty tendency to convert everything in a calculation to match the smallest data type used anywhere in the calculation. This can really screw you up sometimes.

Like I said, I'll have a look at this in detail in a few hours, and see whether anything comes to mind.
Jun 22 '07 #3
Tophurious
13 New Member
Expand|Select|Wrap|Line Numbers
  1. Private pP As Double 'Pressure of the stream
  2. Private pT As Double 'Temperature of the stream
  3. Private pH As Double 'Enthalpy of the stream
  4. Private pW As Double 'Flow of the stream
  5. Private pType As StreamType 'Type of stream: Steam, Water, Leak(Enum)
  6. Private pName As String 'Name of the stream
  7.  
  8. Property Let P(P As Double)
  9.     pP = P
  10. End Property
  11.  
  12. Property Let T(T As Double)
  13.     If pType = Steam And pP <> 0 Then
  14.         If (T - STMPT(pP)) < 27 Then 'Check for 27 degree superheat per PTC 6
  15.             pT = 0
  16.         Else
  17.             pT = T
  18.         End If
  19.     Else
  20.         pT = T
  21.     End If
  22. End Property
  23.  
  24. Property Let H(H As Double)
  25.     pH = H
  26. End Property
  27.  
  28. Property Let W(W As Double)
  29.     pW = W
  30. End Property
  31.  
  32. Property Get P() As Double
  33.     P = pP
  34. End Property
  35.  
  36. Property Get T() As Double
  37.     If pT = 0 And pH > 0 And pP > 0 Then 'calculate if temp unknown & H known
  38.         If Not SuperHeat Then
  39.             pT = STMPHT(pP, pH)
  40.         End If
  41.     End If
  42.     T = pT
  43. End Property
  44.  
  45. Property Get H() As Double
  46.     H = CalcH
  47. End Property
  48.  
  49. Property Get W() As Double
  50.     W = pW
  51. End Property
  52.  
  53. Property Get SType() As StreamType
  54.     SType = pType
  55. End Property
  56.  
  57. Property Get Name() As String
  58.     Name = pName
  59. End Property
  60.  
  61. Property Get S() As Double 'Get Entropy
  62.     If pT <> 0 And pP <> 0 Then
  63.         S = STMPTS(pP, pT)
  64.     ElseIf pT = 0 And pP <> 0 Then
  65.         S = STMPHS(pP, H)
  66.     End If
  67. End Property
  68.  
  69. Property Get x() As Double 'Get X
  70.     x = STMPHQ(pP, H)
  71. End Property
  72.  
  73. Property Get Q() As Double 'Get Energy Flow Rate (H*W)
  74.     Q = H * pW
  75. End Property
  76.  
  77. Property Get V() As Double 'Get Specific Volume
  78.     V = STMPTV(P, T)
  79. End Property
  80.  
  81. Property Get Density() As Double 'Get Specific Density
  82.     If P = 0 Then
  83.         Density = 62.087 + 0.022519 * T - 0.00033873 * (T ^ 2) + 0.0000010579 * (T ^ 3)
  84.     Else
  85.         Density = 1 / V
  86.     End If
  87. End Property
  88.  
  89. Property Get C() As Double 'Get Specific Heat
  90.     C = 1.0244 - 0.00071715 * pT + 0.0000061796 * (pT ^ 2) - 0.000000016397 * (pT ^ 3)
  91. End Property
  92.  
This problem went away. And KEEPS COMING BACK!!! I switched my computers out and it started working again. Now I have the same sort of issue and we tried it on 3 different computers here. same problem. I run the program and get overflow. but I can hold down F8 for 20 minutes and easily fly past the point at which it crashes. I am so tired of it. I want to use C# or C++ but unfortunately my company does not have licenses for it.
Jun 26 '07 #4
pureenhanoi
175 New Member
This problem went away. And KEEPS COMING BACK!!! I switched my computers out and it started working again. Now I have the same sort of issue and we tried it on 3 different computers here. same problem. I run the program and get overflow. but I can hold down F8 for 20 minutes and easily fly past the point at which it crashes. I am so tired of it. I want to use C# or C++ but unfortunately my company does not have licenses for it.
i tried copy ur code in to a new project and do it. No problem occured. Maybe, u have other statement that i dont know. But i have small idea.
Expand|Select|Wrap|Line Numbers
  1. Property Let H(H As Double)
  2.       pH = H
  3. End Property
  4.  
Here, u let pH = H. H maybe a local varriable in proprerty Let. If this is, no problem occure. But if VB translate H as Property Get H() As Double that u declare. So, this is wrong. I donot ensure how VB translate this, but u shouldnt use the same name for the varriable as the Property name.
Use the same name for Property Let and Property Get only.
Expand|Select|Wrap|Line Numbers
  1. Property Let H (hValue as Double)
  2.      pH = hValue
  3. End Property
  4. Property Get H () As Double 
  5.      H = calH()
  6. End Property
  7.  
Try replacing other Varriables which name as similar as Property name and do ur project again. If it still have error, i must say sorry because i cannot help u any more.
Jun 27 '07 #5
Killer42
8,435 Recognized Expert Expert
That is some weird stuff you've got going on there.

Sorry, I completely forgot about it. I'll e-mail myself a reminder to have a look when I get home tonight.

In the meantime, one straw you could grasp in desperation is to put DefDBL A-Z at the top of the module(s), to indicate a default data type of Double for everything. Probably won't help, but hey, it probably won't hurt.
Jun 27 '07 #6
Killer42
8,435 Recognized Expert Expert
Just a note. As I think on it further, it's not really all that surprising that things can work slightly differently between compiled and interpreted code. After all, if the problem is related to temporary values generated during a calculation, there's no reason why the runtime and IDE code couldn't be using some slightly different code internally to do it.

My guess is that it will probably just end up being necessary to force something to Double format, or split up a calculation (or comparison) to gain finer control over the format conversions. However, I haven't read back through the whole of the thread yet. Will do so tonight.

In the meantime, good luck!
Jun 27 '07 #7
Killer42
8,435 Recognized Expert Expert
Well, I've had a look through the images. I'm going to admit complete bafflement. I've never really done much with classes, and I know things can get complicated due to different memory models, different types of creation/sharing/destruction of objects and so on. For all I know, there might be another instance of something which is working with the same data that you are looking at.
Jun 27 '07 #8

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

Similar topics

12
3154
by: rhmd | last post by:
Just found Python and I love it. What an elegant language! I would like to use it for various applications, but the mathematical calculations are way too slow (a million sines 8 seconds in Python vs. 2 seconds in Excel VBA), so was thinking of learning enough C++ to do the number crunching in C++ and integrating the C++ routines with Python. My question: My question: Which compiler works best with Python? I use Windows XP and 98. Have...
6
6180
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with itself. Everything you need is available at no costs (except download hassle and installation time). Once your system is set up properly its just a matter of running 'python setup.py build'. No longer waiting for someone else to build binaries and a...
10
2237
by: Alan Lee | last post by:
Hi i am writing a small simulation for a bunch of atoms jumping around on a surface. I know i am a crappy programmer since i am not very familiar with object oriented languages. I am woindering if anyone can tell me why my forward class declarations not working. the member function findpaths can't seem to access the class Board when I try to pass it a board object by value. I put the Board class latrerbut also put in a forward...
7
2441
by: Ebay boy | last post by:
I have recently bought a compiler and I have this sample code that includes the following: #include <stdlib.h> #include <string.h> #include <time.h> Unfortunately, my compiler doesn't incude these. So where can I get these files from? I'm a computer idiot so please be clear. Any help is
66
3277
by: Knady | last post by:
Hi, I have the following problem, I must to do my assignment, but I really do not know how to use the malloc. I need create a program that will be used to do some algebrical computation on the matrix. How I can create dynamical the matrices with the name in order to be able to recall them. Thx
17
2546
by: Student | last post by:
Hi All, I have an assignment for my Programming language project to create a compiler that takes a C++ file as input and translate it into the C file. Here I have to take care of inheritance and operator overloading and virtual functions. I mean it should not hamper the C++ meaning. In frank and simple terms i need to implement a small C++ compiler in C++, and i want the intermediate representation to be C. Please help me in this....
5
1877
by: Ark | last post by:
Consider static T foo; .............. T get_foo(void) { return foo; } In a multi-threaded (or -tasked) environment, I need to ensure that I get_foo() grabs T atomically (e.g. is not preempted while accessing foo). Are there types T for which atomic fetch /guaranteed/ portably? Does the
83
4016
by: Anonymous | last post by:
Came across some code summarized as follows: char const* MyClass::errToText(int err) const { switch (err) { case 0: return "No error"; case 1: return "Not enough"; case 2: return "Too much"; default: return "Unknown error";
3
3448
by: Rene | last post by:
Hello to all! For a long time I have been "fighting" a problem compiling an OpenGL program which uses GLUT. First I have put a question in a Watcom group (I want to use this compiler) to which I got no reply, in an OpenGL group somebody recommended me to use Visual C++ which I did. That worked OK but I do would like to use Watcom. In the meantime I found solutions to several of the errors I got but one is left which I cannot find a...
0
9808
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10812
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10523
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10561
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9346
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5638
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3089
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.