|
|
| Author |
Message |
| Yoko |
This post is not being displayed .
|
 Yoko Brolly Dolly

Joined: 25 Feb 2007 Karma :     
|
 Posted: 13:54 - 09 Nov 2007 Post subject: Programming: VB6/VBA |
 |
|
Alright
I'm trying to teach myself Interface Classes and Implementation in VB6/VBA and I cant quite get my head around it.
I'm reading about it in VBA Developers Handbook (By Ken Getz & Mike Gilbert) but its just not clicking in my head.
I've looked at sample code and read up about it but I cant find a simple explanation of it, how it works and the benefits.
So if any of you programmers out there have the answer please can you enlighten me!
 ____________________ Sheep Shagger |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| veeeffarr |
This post is not being displayed .
|
 veeeffarr Super Spammer
Joined: 22 Jul 2004 Karma :     
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Yoko |
This post is not being displayed .
|
 Yoko Brolly Dolly

Joined: 25 Feb 2007 Karma :     
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| TheShaggyDA |
This post is not being displayed .
|
 TheShaggyDA Repost Police

Joined: 14 Jun 2004 Karma :  
|
 Posted: 14:07 - 09 Nov 2007 Post subject: |
 |
|
I'm learning .NET at the mo, and one analogy of an interface class is to think of it as a car radio; although the radio has a pile of coils, chips, and other discrete components, the interface is the bit you interact with - the volume control, tuning knob and station buttons. It means that you don't have to care what is going on in the background, you just know that when you hit a station button, it'll go to that station.
From a DB perspective, it means that you can write a class the allows you to have fixed features - add, delete, change, lookup, without caring whether it's a flat ASCII file or Oracle database in the background.
This means that you write the interface and only specify what it can do, not how it does it. You then write another class that implements that interface. ____________________ Current: CB500 Previous: CB100N, CB250RS, XJ900F, GT550, GPZ750R/1000RX, AJS M16, R100RT, Enfield Bullet
[i:6e3bfc7581]But still I fear and still I dare not laugh at the madman...[/i:6e3bfc7581] |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| TheShaggyDA |
This post is not being displayed .
|
 TheShaggyDA Repost Police

Joined: 14 Jun 2004 Karma :  
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Yoko |
This post is not being displayed .
|
 Yoko Brolly Dolly

Joined: 25 Feb 2007 Karma :     
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| TheShaggyDA |
This post is not being displayed .
|
 TheShaggyDA Repost Police

Joined: 14 Jun 2004 Karma :  
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Yoko |
This post is not being displayed .
|
 Yoko Brolly Dolly

Joined: 25 Feb 2007 Karma :     
|
 Posted: 14:28 - 09 Nov 2007 Post subject: |
 |
|
My simple example...
Class 1
| Code: | Option Explicit
Public Sub x()
MsgBox "Program x"
End Sub |
Class 2
| Code: | Option Explicit
Implements Class1
Private Sub Class1_x()
MsgBox "Program x1"
End Sub
Public Sub y()
Call Class1_x
End Sub |
Std Module
| Code: | Option Explicit
Dim p As Class1
Dim q As Class2
Sub a()
Set p = New Class1
p.x
End Sub
Sub b()
Set q = New Class2
q.y
End Sub |
Sub a calls method x from class1
Sub b calls method y from class2 which implements class1
I would expect b to display a message box with "Program x" then another message box with "Program x1" but it does not. I only get one message box with "Program x1". Thats my interpretation of it. ____________________ Sheep Shagger |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Yoko |
This post is not being displayed .
|
 Yoko Brolly Dolly

Joined: 25 Feb 2007 Karma :     
|
 Posted: 15:09 - 09 Nov 2007 Post subject: |
 |
|
Ah ha!!! The penny has just dropped.
I didnt realise that you are meant to use an interface with more than one class.
Cool so I can write an interface and then two or more classes which have the same functions etc as my interface (or write two classes and a corresponding interface) I can then use either classes via the interface as opposed to instancing each class. ____________________ Sheep Shagger |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
Old Thread Alert!
The last post was made 18 years, 357 days ago. Instead of replying here, would creating a new thread be more useful? |
 |
|
|