How to make a hierarchical structure Class


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to make a hierarchical structure Class

  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Unhappy How to make a hierarchical structure Class

    hi friends ...

    i'm intending to make an application with visual basic 6.0

    the application will solve some design proplems of civil enineering like design a beam , columns

    and also to make a workshop drawing through the program by programming AutoCAD

    to make this i'll make a ActiveX.dll component

    to collect some useful functions of math, registery and so on

    i want to make a parent class named sceeda

    inside the activeX.dll component

    and other classes like Math , Design, and so on

    my question is :
    ****************

    ho to make a hierarchical structure fashion so i can call the math class from the main class Sceeda

    in other words ...


    what code i write inside the ActiveX.dll allowing me to call a function in the Math Class from sceeda Class like this :

    Sceeda.Math.CalculateAverage

    where :

    Sceeda :
    ********
    the main class in the ActiveX.dll and have no functions ( the class is nearely empty)

    Math:
    ******
    the class i wrote the function or procedure called CalculateAverage

    how to make a relation between 2 classes

    i don;t want to call the math class directly from my application like this :

    Math.CalculateAverage


    N.B :

    i'dont want to make inheritence

    but something like aggregation

    any one help me please

    so many thanks

    urs maximas

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Create an ActiveX DLL project (SceedaUtility). Add a new Class module (CSceeda). Add the following code to the class:
    Code:
    Option Explicit
    Public Math As CMath
    
    Private Sub Class_Initialize()
        Set Math = New CMath
    End Sub
    In the Properties Window, set the CSceeda class' Instancing property to MultiUse or GlobalMultiUse.

    Now add a second Class module to the project (CMath). Add the following code to the class:
    Code:
    Option Explicit
    Public Function CalculateAverage(Values() As Double) As Double
    
        Dim Result As Double
    
        ' Calculate average here
    
        CalculateAverage = Result
    
    End Function
    Set this class' Instancing property to PublicNotCreatable. Compile the project to build the DLL.

    Finally, open or create the client project. Set a reference to your new SceedaUtility DLL. In your client code, do this:
    Code:
    Dim Sceeda As CSceeda
    Set Sceeda = New CSceeda
    
    Dim Values(4) As Double
    Dim Average As Double
    Average = Sceeda.Math.CalculateAverage(Values)
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Sep 2007
    Posts
    2

    Smile

    working 100 % successfull

    thank u sir Phil

    urs maximas

Similar Threads

  1. How To Do It - Shared Class Variables Part III
    By Patrick Ireland in forum .NET
    Replies: 5
    Last Post: 05-10-2001, 06:19 PM
  2. How To Do It - Shared Class Variables Part II
    By Patrick Ireland in forum .NET
    Replies: 3
    Last Post: 04-26-2001, 02:50 AM
  3. How to make webdesign world class
    By Anoop in forum Architecture and Design
    Replies: 1
    Last Post: 01-17-2001, 09:15 AM
  4. WinForm Compile Error
    By Robert in forum .NET
    Replies: 1
    Last Post: 10-24-2000, 11:38 AM
  5. Fixed it but..
    By Robert in forum .NET
    Replies: 0
    Last Post: 10-23-2000, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center