Results 1 to 9 of 9

Thread: can i store a class in a DLL?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87

    Question

    i think traditional usage of DLLs is to contain a library of subs and fuctions.

    I've developed a class that I'd like to reuse in projects in the future but I don't want the class code in the project to prevent any temptation to altering it (and maybe breaking my other applications).

    Can I compile just a class into a .DLL and then create an instance of that class in my project?

    ive looked around and haven't found anything like this.

    thanks for any info anyone can provide

  2. #2
    Guest
    Yes, you can compile just a class into an ActiveX Dll.

    Paul

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    You didn't find anything, because in VB, that's what DLLs are meant for, writing classes.

    In VB, you cannot write a DLL without having a class into it, so it's not simply a collection of Subs and Functions.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87

    ahh =)

    thanks for the info..

    is any special notation required when instancing a class that resides in a .DLL instead of a class that resides in the project?

    thanks again

  5. #5
    Guest
    You can either make a reference to the dll and use your class just like you would when referencing any other dll (like when you reference ADO to make connections and recordsets) or use CreateObject. I prefer to make a reference to get the Intellisense support.

    Cheers,
    Paul

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Nope, only in case of DLL, add a reference to it through Project > References.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87

    last question ;)

    you guys have been a big help, thanks

    ive created my class. it has public properties and subs defined, i compile into the DLL and set a reference to it in another project. after i create an instance of my new object i'm not getting any intellisense support.

    something doesn't seem right. Do i have to use regsvr32 with my .DLLs before i can use them?

    thanks =)

  8. #8
    Guest
    You shouldn't have to. How are you instancing your object? After making a reference you should be able to do something like:

    Dim obj As YourClassName

    Set obj = New YourClassName

    obj.WhatEver ' You should get intellisense support here!

    Set obj = Nothing


    Paul

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87
    not sure what happened but ive got intellisense now.. thanks anyway =)

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