Results 1 to 7 of 7

Thread: [RESOLVED] ActiveX DLL and forms

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Huddersfield
    Posts
    4

    Resolved [RESOLVED] ActiveX DLL and forms

    How can I refer to properties and methods of the class I'm building from within the forms that I want to include in the DLL?.

    e.g:

    CLASS.CLS

    VB Code:
    1. private localvalue
    2.  
    3. public property get value()
    4.     value = localvalue
    5. end property
    6.  
    7. public sub increasevalue()
    8.     localvalue = localvalue+1
    9. end sub


    FORM.FRM
    VB Code:
    1. sub command1_click()
    2.     if value() > 100 then
    3.         text1.text = value()  ????
    4.     end if
    5. end sub
    I know that in this example I could refer to form.Text1 from the class, but my real life problem can't be solved that way.

    Cheers,

    Simon
    Last edited by WelcomeSinners; Feb 24th, 2005 at 11:43 AM.

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: ActiveX DLL and forms

    Do you want a Form to access methods of a Class, or do you want a Class to access methods from a Form?
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Huddersfield
    Posts
    4

    Re: ActiveX DLL and forms

    I want the form to access methods of the class.

  4. #4
    Lively Member
    Join Date
    Sep 2004
    Posts
    74

    Re: ActiveX DLL and forms

    Quote Originally Posted by WelcomeSinners
    I want the form to access methods of the class.
    then you would need to initialize the class first in youre form code.

    VB Code:
    1. sub command1_click()
    2.    dim name as new class
    3.     if value() > 100 then
    4.         text1.text = name.value()  ????
    5.     end if
    6.    set name = nothing
    7. end sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Huddersfield
    Posts
    4

    Re: ActiveX DLL and forms

    > then you would need to initialize the class first in youre form code

    VB Code:
    1. sub command1_click()
    2.    dim name as new class
    3.     if value() > 100 then
    4.         text1.text = name.value()  ????
    5.     end if
    6.    set name = nothing
    7. end sub

    Thanks for the response. Unfortunately, I don't want the form to access a new instance of the class, I want it to access the pre-existing class that the calling application has created, so it can act on and change the properties within it. Is this possible?

    I've tried

    VB Code:
    1. public oClass as Class

    in the header of the form, and:

    VB Code:
    1. Dim fForm as MyForm
    2. set fForm = new MyForm
    3. fForm.oClass = me

    in the class module, and this compiles to a DLL. However when I call, from the main app., a class method that loads the form (which in turn tries to check one of the class properties), I get "Run-time error '91' - Object variable or With block variable not set".


    Cheers,

    Simon
    Last edited by WelcomeSinners; Feb 24th, 2005 at 08:40 AM.

  6. #6
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: ActiveX DLL and forms

    Try changing:
    VB Code:
    1. fForm.oClass = me
    to:
    VB Code:
    1. Set fForm.oClass = me
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Huddersfield
    Posts
    4

    Resolved Re: ActiveX DLL and forms [RESOLVED]

    Fantastic. Thanks for your help, much appreciated.

    Cheers,

    Simon

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