Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3768

Method on a Class? I nearly have it!

$
0
0

Hi,
Trying hard to immerse myself in OOP but I must be missing some fundamental concept.

So I’ve added a Class called Product to a module with various properties (productID,price,description etc.)
I’ve then added a Property to the module called Products() - to store an array of products
I’ve added code to populate the array from database table… all good so far
I’ve then added a Method to the Product class called IndexByProductID which would return the array index of a product for a given ProductID. Seems perfectly logical to me but when I try to use it like this

dim p as integer = GeneralModule.Product.IndexbyProductID(me.ProductID)

I get the error Static reference to instance method: call this on an instance of class GeneralModule.Product

The error sort of makes sense but leaves me unsure how to use the method I’ve created. I assume I’m not quite getting the concept of how/when to use a method on a class. Tried a few searches but if anyone can point me in the right direction in this instance it would be appreciated.
Thanks

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3768

Trending Articles