Re: VB6 Common Code for Access, Excel and VB Projects

From: Howard Kaikow (kaikow_at_standards.com)
Date: 10/01/04

  • Next message: Peter Ammon: "Re: Internet application"
    Date: Fri, 1 Oct 2004 01:59:32 -0400
    
    

    Yes, you must have the code in a class.
    Instantiate the class as, say, YourClass, then qualify each reference to
    code with the classname.
    E.g., if you have a function GetTodaysDate(), then you call the function
    with

    x = YourClass.GetTodaysDate().

    All VB books should be explaining this.
    If you do not have such a book, I suggest Gary Cornell's Visual Basic 6 From
    the Ground Up.

    -- 
    http://www.standards.com/; See Howard Kaikow's web site.
    "Tim ffitch" <fia@ifs.inchcape.co.uk> wrote in message
    news:131ac1c1.0409290040.7ed6a15c@posting.google.com...
    > Hi
    >
    > Thanks for your reply. Perhaps I should have gone into a bit more
    > detail. I have done what you said but I cant call my functions unless
    > I instantiate an object from my class and then call the function
    > procedures from the object. I have tried to create an ActiveX DLL with
    > standard code modules instead of a class. I have tried this with and
    > without a class module included as well. If I remove the class module
    > I am not able to compile the project.
    >
    > Any ideas where I may be going wrong?
    >
    > Kind regards
    > Tim ffitch
    >
    > "Howard Kaikow" <kaikow@standards.com> wrote in message
    news:<cjc7i9$e7g$1@pyrite.mv.net>...
    > > Compile the code to an ActiveX DLL and add a reference to each VBA/VB
    > > project that requires use of the DLL.
    > >
    > > -- 
    > > http://www.standards.com/; See Howard Kaikow's web site.
    > > "Tim ffitch" <fia@ifs.inchcape.co.uk> wrote in message
    > > news:131ac1c1.0409280651.1fa6e3c8@posting.google.com...
    > > > Hi
    > > >
    > > > It has been sometime since I have done any pure VB programming. I need
    > > > to set up in Visual Basic 6 something like a dll that has common
    > > > functions I can use in Microsoft Access, Excel and VB Projects. I am
    > > > am sure I did something similar years ago in VB 5.
    > > >
    > > > I have created a class which stores all the code for the function
    > > > procedures but from my projects I have to reference the instance of
    > > > the class instead of just calling the function.
    > > >
    > > > I am sure I did this last time without having to set up a class. I
    > > > have tried a Standard Exe project but it wont allow me to connect to
    > > > it.
    > > >
    > > > Any ideas please?
    > > >
    > > > Kind regards
    > > > Tim ffitch
    

  • Next message: Peter Ammon: "Re: Internet application"

    Relevant Pages

    • Re: VB6 Common Code for Access, Excel and VB Projects
      ... without a class module included as well. ... Tim ffitch ... > Compile the code to an ActiveX DLL and add a reference to each VBA/VB ...
      (comp.programming)
    • Re: Add Property to MS VB Objects
      ... I do this when subclassing a control as I usually implement additional functionality via a class module (for example, functionality not exposed by VB's ListView control, but is available using the API, so I pass a reference to the ListView control I want "enhanced"). ... You just have to be sure to destroy the local reference BEFORE the winproc procedure falls off the stack; ... Public Declare Function SetProp Lib "user32" Alias "SetPropA" (ByVal hwnd As Long, ByVal lpString As String, ByVal hData As Long) As Long ...
      (microsoft.public.vb.general.discussion)
    • Re: Passing by reference
      ... It depends upon the reason one is passing the reference. ... instantiate all relationships via a constructor so there will always be ... I naturally think of 'getter' methods as 'knowledge ...
      (comp.object)
    • Re: Best Practices Questions - Sending objects to/from a class modules/functions, etc?
      ... > class module. ... Passing a Reference Type by ... Passing a Reference Type by Val passes a reference to the object, ... I can dispose of the returned object when I'm ...
      (microsoft.public.dotnet.general)
    • Re: calling from one workbook the classes and functions in another
      ... having discovered the vb trick recently I'm suddenly a big fan ... > reference to the instantiated class. ... you can't instantiate the class. ... >> Copy your cls into a VB Project for an activex dll. ...
      (microsoft.public.excel.programming)