same .cls multiple .dvbs sync problem

Discussion in 'AutoCAD' started by Mark Propst, Apr 19, 2004.

  1. Mark Propst

    Mark Propst Guest

    Hi all,
    I have various dvbs, bas, cls, frm etc files.
    I put reusable funcs/subs in a util.cls and reference that into dvbs as
    needed.
    Over time more funcs/subs are added as projects/ideas evolve.

    the current question involves keeping all dvbs up to date.(using same .cls,
    ..bas, .frm files)

    problem:
    Autocad vba .dvbs keep a copy of the original file at time of import.
    (rather than reading from disk like vb does)

    Thus every .dvb that references Util.cls will have a different version of
    the file, as it evolves over time.

    The only way I know how to update a .cls is to remove(without
    saving-exporting) the .cls then re-import from disk.

    if hundreds of dvbs reference the same util.cls - or whatever file - that's
    a huge project every time you add to or change a class definition.

    Am I missing something obvious here?

    That would mean every time I change a "reusable" file(with multiple
    "references") I would have to open and edit hundreds(or however many)
    projects in folder to see if it contains that file and then
    'detach-reattach' to update the files.

    Of course it sounds like something i can do with the vbe model....
    still it doesn't seem intelligent that they would structure it this way, so
    I still wonder if I'm misunderstanding the situation....

    Tia for any insights
    Mark
     
    Mark Propst, Apr 19, 2004
    #1
  2. Yes, you are missing the fact that you can reference a _VBA project_. Store
    you class in a separate project and reference that project from the projects
    that need that class. Do not import the class module itself.


    --
    R. Robert Bell


    "Mark Propst" <notmark-at-atreng-dot-com> wrote in message
    Hi all,
    I have various dvbs, bas, cls, frm etc files.
    I put reusable funcs/subs in a util.cls and reference that into dvbs as
    needed.
    Over time more funcs/subs are added as projects/ideas evolve.

    the current question involves keeping all dvbs up to date.(using same .cls,
    ..bas, .frm files)

    problem:
    Autocad vba .dvbs keep a copy of the original file at time of import.
    (rather than reading from disk like vb does)

    Thus every .dvb that references Util.cls will have a different version of
    the file, as it evolves over time.

    The only way I know how to update a .cls is to remove(without
    saving-exporting) the .cls then re-import from disk.

    if hundreds of dvbs reference the same util.cls - or whatever file - that's
    a huge project every time you add to or change a class definition.

    Am I missing something obvious here?

    That would mean every time I change a "reusable" file(with multiple
    "references") I would have to open and edit hundreds(or however many)
    projects in folder to see if it contains that file and then
    'detach-reattach' to update the files.

    Of course it sounds like something i can do with the vbe model....
    still it doesn't seem intelligent that they would structure it this way, so
    I still wonder if I'm misunderstanding the situation....

    Tia for any insights
    Mark
     
    R. Robert Bell, Apr 19, 2004
    #2
  3. Mark Propst

    Mark Propst Guest

    Thankyouthankyouthankyouthankyou...etc
    :)

    so references are read from disk on project open?

    I knew I could create a dll and compile and reference that, but didn't know
    you could use a regular project in that way.
     
    Mark Propst, Apr 19, 2004
    #3
  4. Mark Propst

    Ed Jobe Guest

    However, you can't directly create an instance of a class that is referenced
    in vba. Here's the steps I use to do this, given Frank's vlax.cls and your
    utils.dvb.

    Add vlax.cls to utils.dvb (assuming a project name of Utils).
    Set vlax's Instancing property to PublicNotCreateable.
    Then in a public module (MyClasses for example) create a function that
    returns an instance. Such as:

    Public Function CreateVLAXClass() As VLAX
    Dim objTemp As VLAX
    Set objTemp = New VLAX
    Set CreateVLAXClass = objTemp
    End Function

    Reference utils.dvb in another project.
    Set an object var using the function.

    Dim oVLAX as VLAX
    set oVLAX = Utils.MyClasses.CreateVLAXClass()
     
    Ed Jobe, Apr 19, 2004
    #4
  5. Mark Propst

    Mark Propst Guest

    now wait a minute guys...
    you're confusing me here.
    :)

    are you saying RRB is handing out bogus information!?!
    horrors!?! :)

    does this mean if I reference a class, the subs and functions are not
    available at all?
    Since I cant' create an instance?

    or was robert implying that it would magically put everything to global
    access without a class instance?

    I'll try both suggestions and see what happens but any clarification would
    be appreciated

    Thanks to both of you.
    (i think) :)
    Mark
     
    Mark Propst, Apr 20, 2004
    #5
  6. Mark Propst

    Mark Propst Guest

    Okay Mister Bell,
    I give up...What's the trick?


    I created a new project.
    Imported cmnUtils.cls
    Saved as cmnToolsPrj.dvb
    Unloaded cmnToolsPrj.dvb
    created a new project.
    Saved as TestCmnToolsPrj.dvb
    set a reference by browsing to cmnToolsPrj.dvb
    the vbaide put a "References" folder under the project, containing
    "Reference to cmnToolsPrj.dvb"

    it also loaded cmnToolsPrj.dvb as another project (according to the Project
    explorer)

    in ThisDrawing module of TestCmnToolsPrj.dvb I put this sub

    Sub test()
    Dim bReady As Boolean

    'tried all of the following (one at a time)

    Dim ct As New CmnToolsPrj (object browser had this on the list)
    'gave error Expected User defined type, not project

    bReady = CmnToolsPrj.cmnutil.acadisready
    'gave error Method or data member not found

    bReady = cmnutil.acadisready
    'gave error variable not defined

    bReady = acadisready
    'gave error variable not defined

    Debug.Print bReady
    End Sub



    However, as Ed points out, I can't seem to get at anything inside the dvb
    project reference.
    However, I know you wouldn't have presented that solution if it didn't work.
    I'm just not doing something right.
    any pointers?
    tia
    Mark
     
    Mark Propst, Apr 20, 2004
    #6
  7. I have my AU class on classes from last year. I'll send it to you, as it is
    easier for you to read it, rather than describe it again.


    --
    R. Robert Bell


    "Mark Propst" <notmark-at-atreng-dot-com> wrote in message
    Okay Mister Bell,
    I give up...What's the trick?


    I created a new project.
    Imported cmnUtils.cls
    Saved as cmnToolsPrj.dvb
    Unloaded cmnToolsPrj.dvb
    created a new project.
    Saved as TestCmnToolsPrj.dvb
    set a reference by browsing to cmnToolsPrj.dvb
    the vbaide put a "References" folder under the project, containing
    "Reference to cmnToolsPrj.dvb"

    it also loaded cmnToolsPrj.dvb as another project (according to the Project
    explorer)

    in ThisDrawing module of TestCmnToolsPrj.dvb I put this sub

    Sub test()
    Dim bReady As Boolean

    'tried all of the following (one at a time)

    Dim ct As New CmnToolsPrj (object browser had this on the list)
    'gave error Expected User defined type, not project

    bReady = CmnToolsPrj.cmnutil.acadisready
    'gave error Method or data member not found

    bReady = cmnutil.acadisready
    'gave error variable not defined

    bReady = acadisready
    'gave error variable not defined

    Debug.Print bReady
    End Sub



    However, as Ed points out, I can't seem to get at anything inside the dvb
    project reference.
    However, I know you wouldn't have presented that solution if it didn't work.
    I'm just not doing something right.
    any pointers?
    tia
    Mark
     
    R. Robert Bell, Apr 20, 2004
    #7
  8. Mark Propst

    Mark Propst Guest

    Hi Ed,
    Thanks again for your example.
    At first I got confused thinking the vlax class had something to do with
    using a reference to a dvb --- as opposed to just an example of the
    technique.
    After re-reading your example and another example by RRB, it finally sank in
    what you guys were doing.
    Thanks again for your help and patience.
    :)
    Mark
     
    Mark Propst, Apr 20, 2004
    #8
  9. Mark Propst

    Mark Propst Guest

    Actually, I do have another tiny question for you.

    is there anything wrong with doing this?

    Public Function CreateVLAXClass() As VLAX
    Set CreateVLAXClass = New VLAX
    End Function

    Mark
     
    Mark Propst, Apr 20, 2004
    #9
  10. Mark Propst

    Ed Jobe Guest

    Not if it works. :) Truthfully, I can't remember right now why I did it
    that way.
     
    Ed Jobe, Apr 20, 2004
    #10
  11. Mark Propst

    Mark Propst Guest

    I only asked because I find myself doing that all the time and then when I
    step back and look at it later I wonder if I can just dispense with the
    interim variable
    Don't know if that is *better* in any way - in my progs it would never be
    detectable in terms of speed or any thing else I'm sure.

    Thanks again for the help.
    Mark
     
    Mark Propst, Apr 20, 2004
    #11
  12. Mark Propst

    Ed Jobe Guest

    Here is a link to info on the Instancing property.
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbproCreatable.asp.
    In vba, only the constants 1 and 2 are available for a class module. If the
    Instancing prop is the default, Private, then you won't even see the class
    object in the Intellisense dropdown. If it is PublicNotCreatable, you can
    see the object but Not be able to Create it. You can only use it if the
    component or container of the class creates it for you.
     
    Ed Jobe, Apr 20, 2004
    #12
  13. Mark Propst

    Ed Jobe Guest

    BTW, if you try to create it with the New keyword, you will get a compile
    error: "Invalid use of New keyword."
     
    Ed Jobe, Apr 20, 2004
    #13
  14. Mark Propst

    Ed Jobe Guest

    Oh, another BTW, Robert and I didn't contradict each other. More like he
    gave you the first half and I gave you the second half. He was just focusing
    on your original request with a simple statement. I was just giving you a
    heads-up on what you would run into by implementing it.
     
    Ed Jobe, Apr 20, 2004
    #14
  15. Mark Propst

    Mark Propst Guest

    Got that!
    thanks again
    Mark
     
    Mark Propst, Apr 20, 2004
    #15
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.