interface usage question

E

Eric

New to interfaces in VBA and getting an error that my class needs to
implement a method that it sure looks like it's doing! Is it because the
method is the Get of a Property??
[Error: Object Module needs to implement method 'LastID' from 'Interface
IAutoIdIncrementer']

Tia, Eric

========================================================================
Interface
'---------------------------------------------------------------------------------------
' Module : IAutoIdIncrementer
' Purpose : Interface for any class that needs to increment an ID
' Precon(s) : A portion of the id is always assumed to be numeric (so we can
apply simple
' addition to it), the interface makes no assumptions about
whther the ultimate
' id is actually a string or a number. That is an
implementation detail, allowing
' for custom id's that are not entirely numeric. The numeric
portion should be a
' long, however.
'---------------------------------------------------------------------------------------
Option Explicit

Public Property Get LastId() As Variant
End Property

Public Property Get NextId() As Variant
End Property

========================================================================
Class Implementation (start - won't compile as is)
'---------------------------------------------------------------------------------------
' Module : CAutoIdIncrementerExcel
' Purpose : Increment ID's where the id data is stored in and used in
Excel
'---------------------------------------------------------------------------------------
Option Explicit

Implements IAutoIdIncrementer
Private mvLastId As Variant
Private mvNextId As Variant

Public Property Get LastId() As Variant
LastId = mvLastId
End Property

Public Property Get NextId() As Variant
NextId = mvNextId
End Property
 
L

Lance Wynn

Hi,

In your implementation class, you need to name the properties
IAutoIdIncrementer_LastID() and IAutoIdIncrementer_NextID()
Once you add the line: Implements IAutoIdIncrementer, you should be able to
pick "IAutoIdIncrementer" from the dropdown at the top-left of your code
window, and then pick each of the implemented methods from the drop down on
the top-right, and it will automatically create the method with the correct
syntax for you.

Lance


New to interfaces in VBA and getting an error that my class needs to
implement a method that it sure looks like it's doing! Is it because the
method is the Get of a Property??
[Error: Object Module needs to implement method 'LastID' from 'Interface
IAutoIdIncrementer']

Tia, Eric

========================================================================
Interface
'---------------------------------------------------------------------------------------
' Module : IAutoIdIncrementer
' Purpose : Interface for any class that needs to increment an ID
' Precon(s) : A portion of the id is always assumed to be numeric (so we can
apply simple
' addition to it), the interface makes no assumptions about
whther the ultimate
' id is actually a string or a number. That is an
implementation detail, allowing
' for custom id's that are not entirely numeric. The numeric
portion should be a
' long, however.
'---------------------------------------------------------------------------------------
Option Explicit

Public Property Get LastId() As Variant
End Property

Public Property Get NextId() As Variant
End Property

========================================================================
Class Implementation (start - won't compile as is)
'---------------------------------------------------------------------------------------
' Module : CAutoIdIncrementerExcel
' Purpose : Increment ID's where the id data is stored in and used in
Excel
'---------------------------------------------------------------------------------------
Option Explicit

Implements IAutoIdIncrementer
Private mvLastId As Variant
Private mvNextId As Variant

Public Property Get LastId() As Variant
LastId = mvLastId
End Property

Public Property Get NextId() As Variant
NextId = mvNextId
End Property
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top