No announcement yet.

VB6: Does anyone have experience with adding moudlarity to their apps?

  • Filter
  • Time
  • Show
Clear All
new posts

  • VB6: Does anyone have experience with adding moudlarity to their apps?

    I am been around VB6 for a while now an have built some pretty extensive applications with it. I have yet to be able to familiarize myself with adding modulatity though. What I'd like to be able to do it have a main application and allow users to download a file and place it in the app directory or run an installer. This will give them that functionality. This way I can upgrade a certain module of my application each time, and allow for many different options.

    I guess some sort of .dll or .ocx, but it needs to be able to be loaded and run after the application is built and out. I also want to be able to make new addons and have the VB detect their existance and load them too. Do you know of any tutorials or pages about this type of functionality?

    I have been looking around on Google, but what generally comes up is stuff about VB Modules, not what I need.


  • #2
    Well, I know that in VB.NET what you are looking for is a Interface. You would have an interface that a class from a DLL would implement. That way your original code can load the .DLL into memory and then create an instance of the class and call the implemented functions on the instanciated class.
    Software Developed:
    DS-ATX Controller Interface
    Laptop Shutdown Controller

    Considered Projects:
    TPMS Interface
    Bluetooth Handsfree Interface (WIDCOMM/BROADCOMM)


    • #3
      Under VB6 the trick is "Late Binding". It all gets a bit messy and is not particularly well documented but you use CreateObject("PackageName.ObjectName") to get an instance of some registered object, then from there you need to have some standard "plugin" interface that you require from third party developers so that you can call the functions etc. E.G. you may require that all valid plugins have a name property so it might go ...

      function loadplugin(byval pluginObjectName as string) as object
      dim result as object
      set result = nothing ' assume failure
      on error goto fail
      set result = createobject(pluginObjectName)
      if result.Name="" then set result = nothing ' We dont allow blank plugin names
      set loadplugin = result ' return object if ok.
      exit function

      set result = nothing ' either object not registered or didnt implement name
      set loadplugin = result
      end function

      this function would return and instance of an object registered with the supplied classid as long as it implemented a member called name that returns a non-blank string. ActiveX controls are even messier; look into controlextender.