Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Definition No Parameter but is called with a parameter

Status
Not open for further replies.

daughtery

Programmer
Dec 12, 2006
66
US
I have a call to a class function, method (whichever name is used, I get mixed up). The call is as follows:
Code:
Set poCatalogGeoCode = goCatalog.CatalogGeoCode(CStr(Val(lvwCatalogGeocode.SelectedItem.key)))
But the definition of CatalogGeocode is as follows:


Code:
Public Property Get CatalogGeoCode() As clsCatalogGeoCodeCollection
    If poCatalogGeoCode Is Nothing Or plPreviousCatalogID <> plCatalogID Then
        Set poCatalogGeoCode = New clsCatalogGeoCodeCollection
            poCatalogGeoCode.LoadCatalogGeocode plCatalogID
    End If
        Set CatalogGeoCode = poCatalogGeoCode
    
    plPreviousCatalogID = plCatalogID
End Property

How is this call working?
 
I have a call to a class function, method

No you don't You are setting/writing a Property of a class

and the definition in the code you post is the other half of the property set/get pair

So in short, there is some otehr code in your class that you have missed (seach the class for Property)

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
I don't have a "Property Set CatalogGeoCode" Is it possible that the property is set from within some other function? the Init function isn't used
 
Aaarg

IGNORE MY PREVIOUS POST - Total rubbish

I've looked again

You are not writing/setting an object property, but reading it. The code you have posted is quite correct and appropriate



the key is in this line and coloured red
Code:
Public Property Get CatalogGeoCode() As [COLOR=red]clsCatalogGeoCodeCollection[/color]

The Property get is returning a collection, and then the rest of the line lvwCatalogGeocode.SelectedItem.key is retrieving the element.

it a shorthand for this
Code:
dim mcol as clsCatalogGeoCodeCollection

set mcol = goCatalog.CatalogGeoCode ' retrieve collection

poCatalogGeoCode = mcol.item(cstr(val(lvwCatalogGeocode.SelectedItem.key )) ' retrieve item from collection




Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
So, daughtery, if clsCatalogGeoCodeCollection has a default Item property, then it might help to write it like this, and make it a little clearer:

Set poCatalogGeoCode = goCatalog.CatalogGeoCode[red].Item[/red](CStr(Val(lvwCatalogGeocode.SelectedItem.key)))


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top