Results 1 to 10 of 10

Thread: [RESOLVED] Store functions into DLL and call at Run Time ???

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Resolved [RESOLVED] Store functions into DLL and call at Run Time ???

    This may seem a little odd and I have never done anything like this so I hope someone could help me here.

    I have an app that has some subs stored in a module. The problem is that I have to adjust these subs from time to time but I don't want to prompt the user to install a whole upgrade every time I make changes to a few lines of code in the sub.

    What I would like to do is simply take these subs and compile them into a dll or anything else that works and have them loaded when the app runs. I have at least 13 reasons to need this,,,

    Is anything like this possible without creating a ton of complicated code? If yes, HOW? could I do this or something similar?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: Store functions into DLL and call at Run Time ???

    Oh, I have no problem supplying the user with an upgrade of that potential external "sub holder"

  3. #3
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Store functions into DLL and call at Run Time ???

    using a an ActiveX dll is your perfect solution.

    to do that, you need to start a new activeX dll project. vb automatically adds a class.
    store all your fucntions in this class.

    if you want separate class for each group of functions (say Cfile.cls for file fucntions), then do so.

    change the property of the class to multiuse

    compile the project and reference the dll in your app.

    you can as well add the whole dll project to your app project so that you can step through code when debugging.

    to use any of the functions in the dll project class say (Cflie.cls) do this

    at module level

    dim oFileFunctions as CFile

    'in the sub or function you need the functions, do this

    set oFileFunctions = new CFile

    strFileContents=oFileFunctions.ReadFile(args)

    try it out!

    i hope it helps
    Last edited by coolcurrent4u; Jun 20th, 2009 at 04:29 PM. Reason: typo
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: Store functions into DLL and call at Run Time ???

    And I can initialize it when I need it right? Just like any other ActiveX?

    I am looking for a minimalistic example somewhere to get me to understand the concept, all I am finding is just toooo much code. I like to start SMALL ... but I see where you are going with this,, I was just poking around and was led in the same direction as you are suggesting.

    Do you happen to know if there is an idiot proof example of this somewhere,,, like Form1.exe and cls1.dll and A+B=C in it?

    Thanks for the help

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: Store functions into DLL and call at Run Time ???

    Awesome,,,, I think I found something that helps me get it. It is here:
    http://www.xtremevbtalk.com/archive/...hp/t-7290.html

    One question,,,,
    If I need to reference another active x components for the dll code to work, do I reference it in the active x project as I would in a normal project?

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Store functions into DLL and call at Run Time ???

    You can read over this short tutorial. Suggest googling for other "ActiveX DLL tutorial" links.

    If you choose to use a DLL, the DLL will have to be distributed along with your exe.

    We posted at the same time. Your DLL project is its own project. Reference whatever is required in that project.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: Store functions into DLL and call at Run Time ???

    Thanks LaVolpe I am wrapping my head around it,, it is not as bad as I thought it might be,, in fact this is incredibly useful,, !!where have I been so far!!!! lol,,,

    I am getting it and it is working out fine for what I need

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: Store functions into DLL and call at Run Time ???

    Ok,, one last question and I think I have it down,,,

    When a dll is upgraded and it gets replaced on user's machine does it have to be re-registered? (Would make sense to me,,, but I have to make sure)

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Store functions into DLL and call at Run Time ???

    Depends on what is upgraded. If you are simply modifying the interior code of an existing function, then no, not as long as the Binary Compatibility option is checked in the project properties window. However, if you add new functions, remove functions, or modify the return value/parameter information of a function, then yes. And if the Binary Compatibility option is checked, you should get a warning that it can't be compiled using the same compatibility (indication new DLL will need to be re-registered). If the binary compatibility option is not selected, then the answer is always yes.

    You can read a bit on this from a great VB5-related book (applies to VB6 also). Don't expect to understand it all, it may seem a bit heavy.

    I am not an expert on "DLL hell" but others are in the forum. They may opt to pipe in. Google "DLL Hell", it is a real programming term.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: Store functions into DLL and call at Run Time ???

    alright, I get it... thank you

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