|
-
Nov 24th, 2000, 05:34 PM
#1
Thread Starter
Addicted Member
Hi,
I've been looking at a quite a number of vb programs and I noticed that in some of them the use the vb keyword
Implements.
Let's say that I have two Classes : clsStudent, clsClass
If in clsClass I have something like ...
Implements clsStudents
Please explain to me it's purpose and why I would want to use Implements.
-
Nov 25th, 2000, 03:36 AM
#2
Addicted Member
hi omarswan!!!
It's the first step from vb to OOP.
The statement "implements clsStudents" in a class module insert you all methodes an properties of the clsStudents.
Note no code!!!!
Sharing the declarations through the Implements statement, no class has to make any declarations itself.
So you can define a class with all methodes and properities which all of your classes needed. (e.g. Database update,
delete ....)
For more information look at
http://msdn.microsoft.com/library/de...Implements.htm
-cu TheOnly
-
Nov 25th, 2000, 10:07 AM
#3
Lively Member
Ok, here goes ...
Let us say that you are writing a driver type interface (Note: We are NOT talking windows drivers here) then you may want to define an interface for, let us say, a thermal printer. This would be implemented as a common interface class and then the specific requirements for each printer could be coded.
Example:
class IThermal
public sub DrawLine(x,y)
end sub
public sub DrawBox(t,l,h,w)
end sub
now the implementations
class EpsonThermal
implements IThermalPrinter
public sub IThermal_DrawLine(x,y)
... actual code to draw the line on the Epson thermal ...
end sub
public sub IThermal_DrawBox(t,l,h,w)
... actual code to draw the line on the Epson thermal ...
end sub
class HPThermal
implements IThermalPrinter
public sub IThermal_DrawLine(x,y)
... actual code to draw the line on the HP thermal ...
end sub
public sub IThermal_DrawBox(t,l,h,w)
... actual code to draw the line on the HP thermal ...
end sub
now, within your main program, you would reference IThermal, thus enabling you to access all of the properties/methods as required and validating calls at compile time. However, you can actually use either of the real implementations at run time
dim MyThermal as IThermal
if Epson Then
set MyThermal = CreateObject("EpsonThermal")
else
set MyThermal = CreateObject("HPThermal")
endif
with MyThermal
.DrawLine ...
.DrawBox ...
end with
I hope that at least helps ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|