Interface implementation not executing.

papadilbert

New member
Local time
Yesterday, 17:09
Joined
Nov 29, 2011
Messages
8
To play with writing an interface and implementation I wrote a simple example. The interface "clsSimple" has a field that I named pCustomerName and defined is as String. I created the Public Get and Set properties for CustomerName and wrote no code for them since they would be implemented in the child class.

I created the child class, a form, starting it with "Implements clsSimple".
I coded properties for Get and Set of clsSimple_CustomerName that store and retrieve the string stored in pCustomerName

I coded a subfunction that is invoked by a form button click.
In the subfunction I specified:

Set objSim = new clsSimple
objSim.CustomerName = "George"
Debug.Print objSim.CustomerName

Nothing prints. I stepped through the code during execution and found that the parent Get and Set are being executed instead of the "implemented" Get and Set.

Where have I gone wrong?
 
Try a Property Let() as opposed to Property Set(). Property Set() is for objects and in VBA a string is not an object.
Alternatively, you could try...
Code:
[COLOR="DarkRed"][B]Set[/B][/COLOR] objSim.CustomerName = "George"
... and see what happens.
Welcome to the forum. Interesting question.
Mark
 
Sorry. That was a typo. I did use Let...not Set.
 
Working as coded.

My mistake was that I created an instance of the base class instead of creating an instance of the derived class. DUH.

Case closed.:o
 

Users who are viewing this thread

Back
Top Bottom