Results 1 to 3 of 3

Thread: Using - "Implements"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Question

    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.
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  2. #2
    Addicted Member
    Join Date
    Oct 2000
    Location
    Vienna/Austria
    Posts
    132
    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

  3. #3
    Lively Member
    Join Date
    Oct 2000
    Location
    Leicestershire; ENGLAND
    Posts
    71
    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
  •  



Click Here to Expand Forum to Full Width