Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Can we revisit the "Implements" statement??

Hello again -

I am using Excel 2002 SP3 and am working on a project involving collecting
data from 7-8 different sources with various col formats, etc. It would be
neat if I could use an interface to define some functions to do this task.
Each object would implement the same functions in a slightly different way.

So as a simplified example - I have an interface in a class module called
"iData" defined as the following:

class iData

Public Function foo(whichWS As Worksheet) As Variant


End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)

End Sub

Then I have another class module called "clsDB_Data" defined as follows:

clsDB_Data

Implements iData

Public Function foo(whichWS As Worksheet) As Variant
Dim v As Variant

foo = v
End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)
MsgBox "Hello World!", vbExclamation
End Sub


This looks right to me but when I compile I get the puzzling error message:

Object Module needs to implement 'foo' for interface 'iData'

This message points to the clsDb_Data module.

I'm confused!!

Can anyone explain what is not right about what I am doing? Seems to me
that I am inplementing foo in my derived class module.

Any insight would be greatly appreciated.

Thanks in advance,

Chris (ct60)




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Can we revisit the "Implements" statement??

You will find it easier to get VBA to generate the routine signatures for
you.
Because you are using Implements, it is not just case of copying the routine
form the iData, but you have to indicate the interface in the call as well.

After you have entered "Implements iData", go to the combo at the top left
of the code pane, where it says "Worksheet" if you are on a WS module.
Select iData, then select each of the routine from the right hand combo,
until you have all of the routine exposed by the interface.

You will notice that the signature are somewhat "special".

NickHK

"ct60" ...
Hello again -

I am using Excel 2002 SP3 and am working on a project involving
collecting
data from 7-8 different sources with various col formats, etc. It would
be
neat if I could use an interface to define some functions to do this task.
Each object would implement the same functions in a slightly different
way.

So as a simplified example - I have an interface in a class module called
"iData" defined as the following:

class iData

Public Function foo(whichWS As Worksheet) As Variant


End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)

End Sub

Then I have another class module called "clsDB_Data" defined as follows:

clsDB_Data

Implements iData

Public Function foo(whichWS As Worksheet) As Variant
Dim v As Variant

foo = v
End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)
MsgBox "Hello World!", vbExclamation
End Sub


This looks right to me but when I compile I get the puzzling error
message:

Object Module needs to implement 'foo' for interface 'iData'

This message points to the clsDb_Data module.

I'm confused!!

Can anyone explain what is not right about what I am doing? Seems to me
that I am inplementing foo in my derived class module.

Any insight would be greatly appreciated.

Thanks in advance,

Chris (ct60)






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Can we revisit the "Implements" statement??

Thanks Nick - that is extremely cool! It is a bit weird to have to do it
that way but I guess it is sort of a vb style way to achieve this.

The Microsoft documentation is very weak in this important area.

I really hope a lot of people see this answer because it is a great way to
make code much more OO.

Best Regards,

Chris


"NickHK" wrote:

You will find it easier to get VBA to generate the routine signatures for
you.
Because you are using Implements, it is not just case of copying the routine
form the iData, but you have to indicate the interface in the call as well.

After you have entered "Implements iData", go to the combo at the top left
of the code pane, where it says "Worksheet" if you are on a WS module.
Select iData, then select each of the routine from the right hand combo,
until you have all of the routine exposed by the interface.

You will notice that the signature are somewhat "special".

NickHK

"ct60" ...
Hello again -

I am using Excel 2002 SP3 and am working on a project involving
collecting
data from 7-8 different sources with various col formats, etc. It would
be
neat if I could use an interface to define some functions to do this task.
Each object would implement the same functions in a slightly different
way.

So as a simplified example - I have an interface in a class module called
"iData" defined as the following:

class iData

Public Function foo(whichWS As Worksheet) As Variant


End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)

End Sub

Then I have another class module called "clsDB_Data" defined as follows:

clsDB_Data

Implements iData

Public Function foo(whichWS As Worksheet) As Variant
Dim v As Variant

foo = v
End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)
MsgBox "Hello World!", vbExclamation
End Sub


This looks right to me but when I compile I get the puzzling error
message:

Object Module needs to implement 'foo' for interface 'iData'

This message points to the clsDb_Data module.

I'm confused!!

Can anyone explain what is not right about what I am doing? Seems to me
that I am inplementing foo in my derived class module.

Any insight would be greatly appreciated.

Thanks in advance,

Chris (ct60)







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Can we revisit the "Implements" statement??

Chris,
Yes, it's not advertised much in VBA, but it certainly has its uses, if you
have a suitable structure.
Depending how intend to use this, you can :
Suppose clsDB_Data, clsTH_Data, whatever Implement IData
Dim MyVar as IData
Set MyVar=New clsDB_Data
'..do something
Set MyVar=New clsTH_Data
'etc

NickHK

"ct60" ...
Thanks Nick - that is extremely cool! It is a bit weird to have to do it
that way but I guess it is sort of a vb style way to achieve this.

The Microsoft documentation is very weak in this important area.

I really hope a lot of people see this answer because it is a great way to
make code much more OO.

Best Regards,

Chris


"NickHK" wrote:

You will find it easier to get VBA to generate the routine signatures for
you.
Because you are using Implements, it is not just case of copying the
routine
form the iData, but you have to indicate the interface in the call as
well.

After you have entered "Implements iData", go to the combo at the top
left
of the code pane, where it says "Worksheet" if you are on a WS module.
Select iData, then select each of the routine from the right hand combo,
until you have all of the routine exposed by the interface.

You will notice that the signature are somewhat "special".

NickHK

"ct60" ...

Hello again -

I am using Excel 2002 SP3 and am working on a project involving
collecting
data from 7-8 different sources with various col formats, etc. It
would
be
neat if I could use an interface to define some functions to do this
task.
Each object would implement the same functions in a slightly different
way.

So as a simplified example - I have an interface in a class module
called
"iData" defined as the following:

class iData

Public Function foo(whichWS As Worksheet) As Variant


End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)

End Sub

Then I have another class module called "clsDB_Data" defined as
follows:

clsDB_Data

Implements iData

Public Function foo(whichWS As Worksheet) As Variant
Dim v As Variant

foo = v
End Function

Public Sub boo(ws1 As Worksheet, ws2 As Worksheet)
MsgBox "Hello World!", vbExclamation
End Sub


This looks right to me but when I compile I get the puzzling error
message:

Object Module needs to implement 'foo' for interface 'iData'

This message points to the clsDb_Data module.

I'm confused!!

Can anyone explain what is not right about what I am doing? Seems to
me
that I am inplementing foo in my derived class module.

Any insight would be greatly appreciated.

Thanks in advance,

Chris (ct60)









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
embedding "ISERROR" function into an "IF" statement [email protected] Excel Worksheet Functions 8 January 4th 07 12:01 AM
Call a sub statement in "Personal Macro Workbook" from "ThisWorkbo QC Coug Excel Programming 1 August 26th 05 07:09 PM
Revisit "Close without Saving Changes", please? Ed[_9_] Excel Programming 2 July 18th 03 12:31 AM


All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"