Problems with Paramaters & Class Modules 
Author Message
 Problems with Paramaters & Class Modules

Hi

I have a class module controlling a number of (normal) modules located
within the same DLL.  I am trying to make some variables accessible to all
of the modules within the DLL and am having real problems.

I know I can do it using Properties but I was wondering if there was a more
efficient way.

Steve Clark



Tue, 21 Sep 2004 06:50:46 GMT  
 Problems with Paramaters & Class Modules

Quote:

> I have a class module controlling a number of (normal) modules located
> within the same DLL.  I am trying to make some variables accessible to all
> of the modules within the DLL and am having real problems.

> I know I can do it using Properties but I was wondering if there was a more
> efficient way.

Will there be more than one instance of this class module?  Could
the shared data simply be a few global (eek!) variables, perhaps
wrapped in a Type so if you need to migrate them later into a class,
you might be able to without overhauling all of your code?  I've
done some "singleton" objects in this way.  Pseudo-code:

class pseudosingleton ' public multiuse

  public enum psmembers ' not really needed, but may be convenient
    psmx
    psmy
    psmz
    psmw
  end enum

  public property get x() as string
    x = globals.singleton.x
  end property

  public property get y() as string
    y = globals.singleton.y
  end property

  public property get z() as string
    z = globals.singleton.z
  end property

  public property get w() as string
    w = globals.singleton.w
  end property

  ' not really needed, but may be convenient
  public property get field(index as variant) as string
    select case lookup(index)
    case psmx: item = x
    case psmy: item = y
    case psmz: item = z
    case psmw: item = w
    case else: err.raise 5
    end select
  end property

  ' not really needed, but may be convenient
  private function lookup(index as variant) as psmembers
    if vartype(index) <> vbstring then
      lookup = index
    else
      select case index
      case "x": lookup = psmx
      case "y": lookup = psmy
      case "z": lookup = psmz
      case "w": lookup = psmw
      case else: err.raise 5
      end select
    endif
  end function
end class

module globals

  private type realsingleton
    x as string
    y as string
    z as string
    w as string
  end type

  global singleton as realsingleon

  private sub main()
    with singleton
      .x = "larry"
      .y = "curly"
      .z = "moe"
      .w = "shemp"
    end with
  end sub
end module

--
Joe Foster <mailto:jlfoster%40znet.com>  Sacrament R2-45 <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Tue, 21 Sep 2004 09:05:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Class Modules & Modules

2. Q(VB5) : Different between module & class module

3. Class Module & Module

4. Class modules 97 - Refering to array within a custom class module

5. Accessing procedures of a class module from another class module

6. Unable To Create SAX Basic Classes & Modules

7. Unable To Create SAX Basic Classes & Modules

8. type statement & class modules

9. Arrays in Class Modules & how to access

10. Class Module & Form together

11. Circular Reference Between Modules when 2 Class Modules Listen to Each others Events

12. Class Module and Module

 

 
Powered by phpBB® Forum Software