Interface implementation not executing. (1 Viewer)

papadilbert

New member
Local time
Today, 02:57
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?
 

MarkK

bit cruncher
Local time
Today, 02:57
Joined
Mar 17, 2004
Messages
8,179
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
 

papadilbert

New member
Local time
Today, 02:57
Joined
Nov 29, 2011
Messages
8
Sorry. That was a typo. I did use Let...not Set.
 

papadilbert

New member
Local time
Today, 02:57
Joined
Nov 29, 2011
Messages
8
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.:eek:
 

Users who are viewing this thread

Top Bottom