fakewalrus
Board Regular
- Joined
- Sep 17, 2007
- Messages
- 56
Working with Excel 2010 Version 14.0.6023.1000 (32 bit)...
I have a project with one Class Module called "Stream"
Inside that class module I have a public function "SpecifyFromUser"
My main subroutine that I am executing is in its own separate module called "CycleCalc"
I also have a number of utility subroutines that reside out in a separate module, for example "IsExpander".
I want the various utility functions to have the capability to manipulate streams that I define in "CycleCalc".
To achieve this, I make the various calculations and then I use the "SpecifyFromUser" function from within this subroutine to manipulate the target stream.
I start off defining all the various streams I have in the "CycleCalc" subroutine, e.g.
Then I go down and initialize the streams inside the "CycleCalc" procedure using my "SpecifyFromUser" function
Everything works great so far. There are no errors associated with the "SpecifyFromUser" function when it's called from within the main "CycleCalc" procedure, but then I get to a part of "CycleCalc" where I call one of the utility subroutines and pass in some streams to it.
The "SpecifyFromUser" function seems to almost always result in a #6 Overflow error being raised whenever I call it from inside one of my utility subroutines, such as "IsExpander". It seems that the error is raised before it actually enters into the "SpecifyFromUser" function, i.e. the debugger seems to take offense to the arguments that I am passing.
BUT the stangest thing is that I have an error handling routine inside the "IsExpander" code and if I use "Resume", the code will proceed as though nothing is wrong. I think for the most part my whole system could work if I just setup the error handlers in all of my various utility routines and tell them to Resume, but I suppose this is adding overhead time as execution jumps to the error handler, sort out whether the error is the predictable sort or other, then returns back again. I would much rather not have the error in the first place.
Also I thought it might be the nature of setting up "SpecifyFromUser" as a function where the return value is really just a dummy, rather than a Sub, but setting it up the other way does not change anything....it still has the same error in the same place.
I have a project with one Class Module called "Stream"
Inside that class module I have a public function "SpecifyFromUser"
Code:
Public Function SpecifyFromUser(SpecPressure As Double, SpecTemperature As Double, SpecMolComp() As Double, Optional SpecMolFlow_lbmolhr As Double, Optional SpecMassFlow_lbmhr As Double) As Long
(Code that performs a bunch of thermodynamic calculations
and stores the results such as flow rates, enthalpies, etc, into private variables in the class module)
End Function
My main subroutine that I am executing is in its own separate module called "CycleCalc"
I also have a number of utility subroutines that reside out in a separate module, for example "IsExpander".
I want the various utility functions to have the capability to manipulate streams that I define in "CycleCalc".
To achieve this, I make the various calculations and then I use the "SpecifyFromUser" function from within this subroutine to manipulate the target stream.
Code:
Public Sub IsExpander(InputStream As Stream, OutputStream As Stream, SpecIsEff As Double, SpecDischargePressure_psia As Double, CalcHP As Double, CalcHead As Double)
Dim DummyOutputPress(0) As Double
Dim DummyOutputTemp(0) As Double
Dim DummyOutputMolFlowrateByComponent() As Double
Dim NComp As Long
On Error GoTo ErrHandler
NComp = InputStream.NumberOfComponents
ReDim DummyOutputMolFlowrateByComponent(NComp - 1) As Double
(Code that calculates DummyOutputPress(0), DummyOutputTemp(0), DummyOutputMolFlowrateByComponent)
(F_to_R is a public constant defined elsewhere)
Dummy = OutputStream.SpecifyFromUser(DummyOutputPress(0), DummyOutputTemp(0) - F_to_R, DummyOutputMolFlowrateByComponent)
Exit Sub
ErrHandler:
Resume
End Sub
I start off defining all the various streams I have in the "CycleCalc" subroutine, e.g.
Code:
Dim E1 As Stream: Set E1 = New Stream
Dim E2 As Stream: Set E2 = New Stream
Then I go down and initialize the streams inside the "CycleCalc" procedure using my "SpecifyFromUser" function
Code:
Dummy = E1.SpecifyFromUser(Range("E1_Press").Cells(1, CaseNumber).Value, Range("E1_Temp").Cells(1, CaseNumber).Value, LiqFeed_MolComposition, , Range("E1_MassFlow").Cells(1, CaseNumber).Value)
Dummy = E2.SpecifyFromUser(Range("E2_Press").Cells(1, CaseNumber).Value, E1.Temp_F - 150, LiqFeed_MolComposition, , E1.MassFlow_lbmhr(2))
Everything works great so far. There are no errors associated with the "SpecifyFromUser" function when it's called from within the main "CycleCalc" procedure, but then I get to a part of "CycleCalc" where I call one of the utility subroutines and pass in some streams to it.
Code:
Call IsExpander(E1, E2, 1, E2.Press_psia, E_hp, E_Head_Is)
The "SpecifyFromUser" function seems to almost always result in a #6 Overflow error being raised whenever I call it from inside one of my utility subroutines, such as "IsExpander". It seems that the error is raised before it actually enters into the "SpecifyFromUser" function, i.e. the debugger seems to take offense to the arguments that I am passing.
BUT the stangest thing is that I have an error handling routine inside the "IsExpander" code and if I use "Resume", the code will proceed as though nothing is wrong. I think for the most part my whole system could work if I just setup the error handlers in all of my various utility routines and tell them to Resume, but I suppose this is adding overhead time as execution jumps to the error handler, sort out whether the error is the predictable sort or other, then returns back again. I would much rather not have the error in the first place.
Also I thought it might be the nature of setting up "SpecifyFromUser" as a function where the return value is really just a dummy, rather than a Sub, but setting it up the other way does not change anything....it still has the same error in the same place.