Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > I am at a total loss for how to fix this


Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2007, 04:32 PM
Tophurious Tophurious is offline
Newcomer
 
Join Date: Jun 2007
Posts: 2
Angry I am at a total loss for how to fix this


I've been trying to get an answer as to why this is happening from different forums on the net and as of yet no one has been able to tell me why it happens or how to fix it. Here is the situation:

Basically, in one of my get methods:
Code:
Property Get H() As Double
    H = CalcH 'This was implemented as the "Back Way" and it fixed problem, before the code in CalcH was in here
End Property
 
Private Function CalcH() As Double
    If pH <= 0# And pT > 0# And pP > 0# Then 'calculate if not set
        pH = STMPTH(pP, pT)
    ElseIf pH <= 0# And pT > 0# Then
        If pType = StreamType.Water Then
            pH = STMTQH(pT, 0#)
        Else
            pH = STMTQH(pT, 1#)
        End If
    ElseIf pH <= 0# And pP > 0# Then
        If pType = StreamType.Water Then
            pH = STMPQH(pP, 0#)
        Else
            pH = STMPQH(pP, 1#)
        End If
    End If
    CalcH = pH
End Function
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
Code:
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

Here is the rest of the class (omited CalcH due to its already posted)
Code:
Private pP As Double 'Pressure of the stream
Private pT As Double 'Temperature of the stream
Private pH As Double 'Enthalpy of the stream
Private pW As Double 'Flow of the stream
Private pType As StreamType 'Type of stream: Steam, Water, Leak(Enum)
Private pName As String 'Name of the stream
 
Property Let P(P As Double)
    pP = P
End Property
 
Property Let T(T As Double)
    If pType = Steam And pP <> 0 Then
        If (T - STMPT(pP)) < 27 Then 'Check for 27 degree superheat per PTC 6
            pT = 0
        Else
            pT = T
        End If
    Else
        pT = T
    End If
End Property
 
Property Let H(H As Double)
    pH = H
End Property
 
Property Let W(W As Double)
    pW = W
End Property
 
Property Get P() As Double
    P = pP
End Property
 
Property Get T() As Double
    If pT = 0 And pH > 0 And pP > 0 Then 'calculate if temp unknown & H known
        If Not SuperHeat Then
            pT = STMPHT(pP, pH)
        End If
    End If
    T = pT
End Property
 
Property Get H() As Double
    H = CalcH
End Property
 
Property Get W() As Double
    W = pW
End Property
 
Property Get SType() As StreamType
    SType = pType
End Property
 
Property Get Name() As String
    Name = pName
End Property
 
Property Get S() As Double 'Get Entropy
    If pT <> 0 And pP <> 0 Then
        S = STMPTS(pP, pT)
    ElseIf pT = 0 And pP <> 0 Then
        S = STMPHS(pP, H)
    End If
End Property
 
Property Get x() As Double 'Get X
    x = STMPHQ(pP, H)
End Property
 
Property Get Q() As Double 'Get Energy Flow Rate (H*W)
    Q = H * pW
End Property
 
Property Get V() As Double 'Get Specific Volume
    V = STMPTV(P, T)
End Property
 
Property Get Density() As Double 'Get Specific Density
    If P = 0 Then
        Density = 62.087 + 0.022519 * T - 0.00033873 * (T ^ 2) + 0.0000010579 * (T ^ 3)
    Else
        Density = 1 / V
    End If
End Property
 
Property Get C() As Double 'Get Specific Heat
    C = 1.0244 - 0.00071715 * pT + 0.0000061796 * (pT ^ 2) - 0.000000016397 * (pT ^ 3)
End Property
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.
Reply With Quote
  #2  
Old 06-28-2007, 12:37 AM
Borix's Avatar
Borix Borix is offline
Regular
 
Join Date: Jun 2007
Posts: 76
Default

Try to enter double types as double: For example, try 1480.0 or CDbl(1480.0) or CDbl(1480) instead of just entering 1480. Maybe this is where the overflow error occurs. In Debug mode though, you may not get this error...
__________________
"Life is simply the reification of the process of living." (E. Mayr)
Reply With Quote
  #3  
Old 06-28-2007, 02:48 AM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Default

How are you calling this routine, and where are the variables declared?
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->