MikeAshton55Mad
New Member
- Joined
- Nov 4, 2004
- Messages
- 49
Hello help desk! 
I have learned so much on this board it's amazing. Of course, it's kept me reaching for more-and-more difficult techniques. Now I'm working on creating a global collection of an object class I've defined.
I have defined: AACurves class, a collection with methods Add, Remove, Clear, Item, and property Count.
AACurve class, an object that has vPoints(360,2) as the property and methods CreateCPICurve and GetCPIfromCurve. These functions work and build the object as they're supposed to.
Now at the module level I'm trying to simply add and retrieve an AACurve object from the AACurve class. Here are the relevant code snippets:
Dim cGlobalCurves As New AACurves
Public Function AACreateCPICurve(WhatToCallIt As String, vSpotDate As Date, vSpotIndex As Double, vvDates As Range, vvRates As Range)
Dim vCurve As New AACurve
vCurve.CreateCPICurve SpotDate:=vSpotDate, SpotIndex:=vSpotIndex, vDates:=vvDates, vRates:=vvRates
cGlobalCurves.Add CurveObject:=vCurve, IndexName:=WhatToCallIt
AACreateCPICurve = WhatToCallIt
End Function
Public Function AAtestgetfromcurve(curvename As String, crvdate As Date)
Dim vCurve As AACurve
Set vCurve = cGlobalCurves.Item(curvename)
AAtestgetfromcurve = vCurve.GetCPIfromCurve(crvdate)
End Function
So, the first function seems to work...and if I use .GetCPIfromCurve in the first function then I get the correct answer back from vCurve. But I'm unable to retrieve the object with the second function. I think it's something to do with the way I'm using the Item method. In AACurves, I've defined the Item method like this:
Public Function Item(IndexName As Variant)
cCurves.Item Index:=IndexName
End Function
The execution of the module-level code seems to end in this function rather than returning to the AAtestgetfromcurve function, so I must be doing something wrong with the syntax?
I'm sure the overall code is pretty ugly-looking to seasoned veterans, but I'm actually pretty pleased with myself. Three months ago I'd never written anything more-elaborate than simple calculator functions...so in other words, don't worry about hurting my feelings by telling me I'm a dolt for not knowing this. I KNOW!
Thanks,
Mike
I have learned so much on this board it's amazing. Of course, it's kept me reaching for more-and-more difficult techniques. Now I'm working on creating a global collection of an object class I've defined.
I have defined: AACurves class, a collection with methods Add, Remove, Clear, Item, and property Count.
AACurve class, an object that has vPoints(360,2) as the property and methods CreateCPICurve and GetCPIfromCurve. These functions work and build the object as they're supposed to.
Now at the module level I'm trying to simply add and retrieve an AACurve object from the AACurve class. Here are the relevant code snippets:
Dim cGlobalCurves As New AACurves
Public Function AACreateCPICurve(WhatToCallIt As String, vSpotDate As Date, vSpotIndex As Double, vvDates As Range, vvRates As Range)
Dim vCurve As New AACurve
vCurve.CreateCPICurve SpotDate:=vSpotDate, SpotIndex:=vSpotIndex, vDates:=vvDates, vRates:=vvRates
cGlobalCurves.Add CurveObject:=vCurve, IndexName:=WhatToCallIt
AACreateCPICurve = WhatToCallIt
End Function
Public Function AAtestgetfromcurve(curvename As String, crvdate As Date)
Dim vCurve As AACurve
Set vCurve = cGlobalCurves.Item(curvename)
AAtestgetfromcurve = vCurve.GetCPIfromCurve(crvdate)
End Function
So, the first function seems to work...and if I use .GetCPIfromCurve in the first function then I get the correct answer back from vCurve. But I'm unable to retrieve the object with the second function. I think it's something to do with the way I'm using the Item method. In AACurves, I've defined the Item method like this:
Public Function Item(IndexName As Variant)
cCurves.Item Index:=IndexName
End Function
The execution of the module-level code seems to end in this function rather than returning to the AAtestgetfromcurve function, so I must be doing something wrong with the syntax?
I'm sure the overall code is pretty ugly-looking to seasoned veterans, but I'm actually pretty pleased with myself. Three months ago I'd never written anything more-elaborate than simple calculator functions...so in other words, don't worry about hurting my feelings by telling me I'm a dolt for not knowing this. I KNOW!
Thanks,
Mike