Results 1 to 6 of 6

Thread: Class and bas modules?

  1. #1

    Thread Starter
    Addicted Member wernerh's Avatar
    Join Date
    Sep 2000
    Posts
    170

    Class and bas modules?

    Hi,

    I have a project with a class module and a bas module.

    Most of my functions in the bas module is used by functions in the class module, which works fine.

    I need to call a function in my class module from my bas module, how can I do this without creating a new instance of my class module in my bas module??

  2. #2
    Lively Member vbJoe's Avatar
    Join Date
    Dec 2003
    Location
    Bus Shelter, Manchester
    Posts
    67

    Thumbs up Only way I know of is...

    Hiya!

    I had to do this a while ago.. I wanted a class to talk back and forward with a module... the only way I found of doing it was to make sure the program knew about the classes that existed.. i.e creating a collection of them..

    This was.. everytime you create a new instance of your main class it gets added to the collection.. like the Controls collection.. when you add a control it gets added to the collection so you can cycle through them..

    I've done a quick example of what I mean, sorry for the crap names but I'm at work and had to hurry it.

    See Attached.
    Attached Files Attached Files
    [vbcode]On Error Goto Pub[/vbcode]

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You obviously got to the function in the bas module through an instance of you class, right? So you should be able to just pass in a reference to the calling class object.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    Addicted Member wernerh's Avatar
    Join Date
    Sep 2000
    Posts
    170
    Thanks!

    Both great ideas, I went with the passing by ref method, works great.

  5. #5
    Lively Member vbJoe's Avatar
    Join Date
    Dec 2003
    Location
    Bus Shelter, Manchester
    Posts
    67

    Unhappy Awww

    Some day someone will use one of my ideas...!


    Waaa
    [vbcode]On Error Goto Pub[/vbcode]

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: Awww

    Originally posted by vbJoe
    Some day someone will use one of my ideas...!


    Waaa
    I use your basic concept all the time when subclassing groups of controls. In that case, its the only way.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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