faust9
05-07-2010, 11:22 AM
Hello,
First time caller, long time listener.
[Short Version] Can I make an array of a custom class and if so how?
I tried this:
Dim EnginePool(250) As engineClass
Set EnginePool(250) = New engineClass
EnginePool(0).initStack 18
The engineClass is a circular buffer that can automatically grow/shrink to simulate a parts pool. The program hangs up when I access the initStack method as an array. If I have "EnginePool.initStack 18" I get an invalid qualifier, so I put "EnginePool(0).initStack 18" to see if I could initialize the data in cell 0. Doing it this way I get: "Object variable or with block variable not set".
Here's the init method:
' set the stack up
Public Function initStack(poolSize As Integer)
' set the starting stack size
poolStartSize = poolSize ' used to redim the pool to the original size
poolmax = poolStartSize ' set the initial Max pool size
poolAbsMax = poolmax ' tracks the max number of parts in the buffer
' initialize the stack
ReDim pool(1 To poolmax)
' point to the first and last entry in the pool (FIFO pool)
last = 1 ' points to last data entry (FIFO)
first = 1 ' points to first data entry (FIFO)
startFlag = 1 ' tells pgm is first and last both point to cell 1 --- the beginning of the pool
emptyFlag = 0 ' tells pgm if the pool is empty (returns Null is set)
End Function
How do I make an array of my custom class? I don't want to spend the time re-writing all of the methods if I don't have to.
Any help would be greatly appreciated.
[Long Version]
OK, here's my quandary. I wrote a custom Monte Carlo simulation for a project. I need to show how much $$$$ can be saved by allowing rebuilt parts to be used, so I wrote some software to simulate the process.
I wrote a class module to act as a re-sizable circular buffer to track the process; however, I have had a new requirement dropped on my desk and I need to track not only rebuilt part usage but also the number of times a rebuilt part gets used. I figured I'd just make an array of engines and track the rebuilt usage and number of times used at the same time.
Essentially, if a part enters the queue I need to know what rebuild level it is and I need to keep that data when that part get used again. That way when the part returns I can increment the times rebuilt counter for that part.
The whole problem is not as easy as it might first seem because each rebuild removes a little material and I need to scrap parts that fall out of spec --- I have this statistical data; moreover, the parts also cannot be rebuilt if they come back and fail for a number of reasons --- again, I have the statistical data to model this.
Well, I hope it's a lot easier than it appears. Anyway, how do I make an array of a custom class? What do I have to do?
Thanks.
First time caller, long time listener.
[Short Version] Can I make an array of a custom class and if so how?
I tried this:
Dim EnginePool(250) As engineClass
Set EnginePool(250) = New engineClass
EnginePool(0).initStack 18
The engineClass is a circular buffer that can automatically grow/shrink to simulate a parts pool. The program hangs up when I access the initStack method as an array. If I have "EnginePool.initStack 18" I get an invalid qualifier, so I put "EnginePool(0).initStack 18" to see if I could initialize the data in cell 0. Doing it this way I get: "Object variable or with block variable not set".
Here's the init method:
' set the stack up
Public Function initStack(poolSize As Integer)
' set the starting stack size
poolStartSize = poolSize ' used to redim the pool to the original size
poolmax = poolStartSize ' set the initial Max pool size
poolAbsMax = poolmax ' tracks the max number of parts in the buffer
' initialize the stack
ReDim pool(1 To poolmax)
' point to the first and last entry in the pool (FIFO pool)
last = 1 ' points to last data entry (FIFO)
first = 1 ' points to first data entry (FIFO)
startFlag = 1 ' tells pgm is first and last both point to cell 1 --- the beginning of the pool
emptyFlag = 0 ' tells pgm if the pool is empty (returns Null is set)
End Function
How do I make an array of my custom class? I don't want to spend the time re-writing all of the methods if I don't have to.
Any help would be greatly appreciated.
[Long Version]
OK, here's my quandary. I wrote a custom Monte Carlo simulation for a project. I need to show how much $$$$ can be saved by allowing rebuilt parts to be used, so I wrote some software to simulate the process.
I wrote a class module to act as a re-sizable circular buffer to track the process; however, I have had a new requirement dropped on my desk and I need to track not only rebuilt part usage but also the number of times a rebuilt part gets used. I figured I'd just make an array of engines and track the rebuilt usage and number of times used at the same time.
Essentially, if a part enters the queue I need to know what rebuild level it is and I need to keep that data when that part get used again. That way when the part returns I can increment the times rebuilt counter for that part.
The whole problem is not as easy as it might first seem because each rebuild removes a little material and I need to scrap parts that fall out of spec --- I have this statistical data; moreover, the parts also cannot be rebuilt if they come back and fail for a number of reasons --- again, I have the statistical data to model this.
Well, I hope it's a lot easier than it appears. Anyway, how do I make an array of a custom class? What do I have to do?
Thanks.