Reusable code

Discussion in 'AutoCAD' started by R.K. McSwain, Sep 3, 2004.

  1. R.K. McSwain

    R.K. McSwain Guest

    I'm interested in opinions regarding reuseable code in AutoCAD VBA.


    .bas files imported into each new project?

    .dvb files that each new project can reference?

    another method?


    TIA
     
    R.K. McSwain, Sep 3, 2004
    #1
  2. Import sucks.

    Use class modules and reference the .dvb file that holds the class. Make the
    class PublicNotCreatable and add a standard module to the class' project
    with a public function similar to:

    Public Function Init() As <MyClassName>
    'Initialization procedure when referencing this project
    Set Init = New <MyClassName>
    End Function


    Then, in the actual project where the class' project is referenced, use
    similar statements in your procedures:
    Dim oTest As <MyClassProjectName>.<MyClassName>
    Set oTest = <MyClassProjectName>.Init



    --
    R. Robert Bell


    I'm interested in opinions regarding reuseable code in AutoCAD VBA.


    .bas files imported into each new project?

    .dvb files that each new project can reference?

    another method?


    TIA
     
    R. Robert Bell, Sep 3, 2004
    #2
  3. I'm interested in opinions regarding reuseable code in AutoCAD VBA.

    .bas files imported into each new project?
    ->->No because if you update the code you have to reimport it for each project.

    .dvb files that each new project can reference?
    ->->Yes.

    another method?
    ->-> If you have VB you can compile a class library.

    ->->Regards - Nathan
     
    Nathan Taylor, Sep 3, 2004
    #3
  4. R.K. McSwain

    Matt W Guest

    Don't hold back, Robert. Tell us how you *really* feel. :)

    That's pretty slick though. What other tricks have you got up your
    sleeve??!?

    --
    Matt W

    <Insert humorous quote or phrase here>

    | Import sucks.
    |
    | Use class modules and reference the .dvb file that holds the class. Make
    the
    | class PublicNotCreatable and add a standard module to the class' project
    | with a public function similar to:
    |
    | Public Function Init() As <MyClassName>
    | 'Initialization procedure when referencing this project
    | Set Init = New <MyClassName>
    | End Function
    |
    |
    | Then, in the actual project where the class' project is referenced, use
    | similar statements in your procedures:
    | Dim oTest As <MyClassProjectName>.<MyClassName>
    | Set oTest = <MyClassProjectName>.Init
    |
    |
    |
    | --
    | R. Robert Bell
    |
    |
    | | I'm interested in opinions regarding reuseable code in AutoCAD VBA.
    |
    |
    | .bas files imported into each new project?
    |
    | .dvb files that each new project can reference?
    |
    | another method?
    |
    |
    | TIA
    |
    |
    |
     
    Matt W, Sep 3, 2004
    #4
  5. R.K. McSwain

    Matt W Guest

    --
    Matt W

    <Insert humorous quote or phrase here>
    | Import sucks.
    |
    | Use class modules and reference the .dvb file that holds the class. Make
    the
    | class PublicNotCreatable and add a standard module to the class' project
    | with a public function similar to:
    |
    | Public Function Init() As <MyClassName>
    | 'Initialization procedure when referencing this project
    | Set Init = New <MyClassName>
    | End Function
    |
    |
    | Then, in the actual project where the class' project is referenced, use
    | similar statements in your procedures:
    | Dim oTest As <MyClassProjectName>.<MyClassName>
    | Set oTest = <MyClassProjectName>.Init
    |
    |
    |
    | --
    | R. Robert Bell
    |
    |
    | | I'm interested in opinions regarding reuseable code in AutoCAD VBA.
    |
    |
    | .bas files imported into each new project?
    |
    | .dvb files that each new project can reference?
    |
    | another method?
    |
    |
    | TIA
    |
    |
    |
     
    Matt W, Sep 3, 2004
    #5
  6. R.K. McSwain

    Matt W Guest

    I don't suppose you have any good "clean" code for the OPEN/SAVE dialog box
    you'd like to share?
    The stuff I have is a compilation from various sources. A real hack job to
    say the least.

    I'll be eagerly awaiting your response while I practice my poker chip
    shuffling. (it's actually quite a good stress-reliever).

    --
    Matt W

    <Insert humorous quote or phrase here>
    | Import sucks.
    |
    | Use class modules and reference the .dvb file that holds the class. Make
    the
    | class PublicNotCreatable and add a standard module to the class' project
    | with a public function similar to:
    |
    | Public Function Init() As <MyClassName>
    | 'Initialization procedure when referencing this project
    | Set Init = New <MyClassName>
    | End Function
    |
    |
    | Then, in the actual project where the class' project is referenced, use
    | similar statements in your procedures:
    | Dim oTest As <MyClassProjectName>.<MyClassName>
    | Set oTest = <MyClassProjectName>.Init
    |
    |
    |
    | --
    | R. Robert Bell
    |
    |
    | | I'm interested in opinions regarding reuseable code in AutoCAD VBA.
    |
    |
    | .bas files imported into each new project?
    |
    | .dvb files that each new project can reference?
    |
    | another method?
    |
    |
    | TIA
    |
    |
    |
     
    Matt W, Sep 3, 2004
    #6
  7. R.K. McSwain

    Matt W Guest

    Looks like I pulled the trigger a little too quickly on that last email...
    whole lotta nuthin'!

    --
    Matt W

    <Insert humorous quote or phrase here>
    |
    |
    | --
    | Matt W
    |
    | <Insert humorous quote or phrase here>
    | | | Import sucks.
    | |
    | | Use class modules and reference the .dvb file that holds the class. Make
    | the
    | | class PublicNotCreatable and add a standard module to the class' project
    | | with a public function similar to:
    | |
    | | Public Function Init() As <MyClassName>
    | | 'Initialization procedure when referencing this project
    | | Set Init = New <MyClassName>
    | | End Function
    | |
    | |
    | | Then, in the actual project where the class' project is referenced, use
    | | similar statements in your procedures:
    | | Dim oTest As <MyClassProjectName>.<MyClassName>
    | | Set oTest = <MyClassProjectName>.Init
    | |
    | |
    | |
    | | --
    | | R. Robert Bell
    | |
    | |
    | | | | I'm interested in opinions regarding reuseable code in AutoCAD VBA.
    | |
    | |
    | | .bas files imported into each new project?
    | |
    | | .dvb files that each new project can reference?
    | |
    | | another method?
    | |
    | |
    | | TIA
    | |
    | |
    | |
    |
    |
     
    Matt W, Sep 3, 2004
    #7
  8. Mike (or someone) recently mentioned controls for that. I have Frank's
    CommonDialog class floating around here too.

    --
    R. Robert Bell


    I don't suppose you have any good "clean" code for the OPEN/SAVE dialog box
    you'd like to share?
    The stuff I have is a compilation from various sources. A real hack job to
    say the least.

    I'll be eagerly awaiting your response while I practice my poker chip
    shuffling. (it's actually quite a good stress-reliever).
     
    R. Robert Bell, Sep 3, 2004
    #8
  9. That rabbit is really starting to annoy me, gotta pull it out of there one
    of these days! ;^)

    P.S. Thanks!

    --
    R. Robert Bell


    Don't hold back, Robert. Tell us how you *really* feel. :)

    That's pretty slick though. What other tricks have you got up your
    sleeve??!?
     
    R. Robert Bell, Sep 3, 2004
    #9
  10. Yeah, if you can hold out for a week Matt, I'm working on an article about
    just that topic and I can send you code once I'm done. Matter of fact if
    there is anything special you are looking for, throw it out - I might just
    get to it [pertaining to Open/Save Dlgs of courses =)]

    As to import vs. reference, I gotta go against Bob for once [I can't
    believe it!] if you are using more than vba. If you are constantly in a
    mixed environment - vba & vb, then import because your cls and bas can be
    used by both [and should be!]. Having them compiled into an inaccessable
    dvb is not very advantageous when you go to do something in full vb. Or use
    a third option which is compile them to a dll and add refs when you need to
    - assumng you have full vb.

    Just my $0.02 to stir up the silt!

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 3, 2004
    #10
  11. One of these day I'm goping to have to learn how to make and use .dll files,
    class modules and more stuff like that. It sound very cool / good.

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    David M. Gardner, Sep 3, 2004
    #11
  12. 8^P

    Actually, I do the .dlls for VB/VBA stuff, but things that are just pure
    AutoCAD VBA I don't bother with it; just use the procedure I outlined.

    Import sucks due to update issues, unless you know something I don't (which
    is extremely likely!).

    --
    R. Robert Bell


    Yeah, if you can hold out for a week Matt, I'm working on an article about
    just that topic and I can send you code once I'm done. Matter of fact if
    there is anything special you are looking for, throw it out - I might just
    get to it [pertaining to Open/Save Dlgs of courses =)]

    As to import vs. reference, I gotta go against Bob for once [I can't
    believe it!] if you are using more than vba. If you are constantly in a
    mixed environment - vba & vb, then import because your cls and bas can be
    used by both [and should be!]. Having them compiled into an inaccessable
    dvb is not very advantageous when you go to do something in full vb. Or use
    a third option which is compile them to a dll and add refs when you need to
    - assumng you have full vb.

    Just my $0.02 to stir up the silt!

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    R. Robert Bell, Sep 3, 2004
    #12
  13. These guys drove me to .dll's kicking and screaming...I like em...once past
    the scary name there just coding...:)
     
    Paul Richardson, Sep 4, 2004
    #13
  14. the scary name there just coding...:)
    "they're" just coding...:)...just in case i was in for a Friday
    butt kicking..ha..
     
    Paul Richardson, Sep 4, 2004
    #14
  15. VB and VBA do not provide much support for reusable code.

    In VB, reusability is primarily via COM. The problem is that
    the language doesn't really support modularity all that well,
    which makes code re-use difficult at best.

    If you're really serious about reusability, perhaps its time to
    look at a different language. Just about every other major
    language is vastly superior to VB in this regards.

    Trust me, once you get the hang of it and experience the
    advantages, you'll never look back.



    I'm interested in opinions regarding reuseable code in AutoCAD VBA.


    .bas files imported into each new project?

    .dvb files that each new project can reference?

    another method?


    TIA
     
    Tony Tanzillo, Sep 4, 2004
    #15
  16. R.K. McSwain

    Mark Propst Guest

    I'm interested in opinions regarding reuseable code in AutoCAD VBA.

    well, since you said opinions rather than knowlege I feel qualified to
    answer.
    :)
    leaves you with multiple versions of same .bas file
    if you change it in one project the changes won't be reflected in other
    projects
    this seems to be the preferred method(according to RRB and EdJobe)
    ?
     
    Mark Propst, Sep 4, 2004
    #16
  17. R.K. McSwain

    Mark Propst Guest

    duh!
    why didn't all those answers you already got show up before i sent this?
    sorry

    news:4139912d_2@newsprd01...
     
    Mark Propst, Sep 4, 2004
    #17
  18. Tony, How can we get a C#(general net) group started?
     
    Paul Richardson, Sep 4, 2004
    #18
  19. A C# newsgroup?? Microsoft has one. The focus here isn't
    language-centric. API-centric, perhaps (e.g., a newsgroup
    for the .NET APIs).
     
    Tony Tanzillo, Sep 4, 2004
    #19
  20. R.K. McSwain

    Matt W Guest

    The only things I'm looking for is:

    1) Clean code (not the hack job that I currently have)
    2) Ability to select more than one file at a time

    What else is there, really?

    --
    Matt W

    I love deadlines
    I like the whooshing sound they make as they fly by.

    | Yeah, if you can hold out for a week Matt, I'm working on an article about
    | just that topic and I can send you code once I'm done. Matter of fact if
    | there is anything special you are looking for, throw it out - I might
    just
    | get to it [pertaining to Open/Save Dlgs of courses =)]
    |
    | As to import vs. reference, I gotta go against Bob for once [I can't
    | believe it!] if you are using more than vba. If you are constantly in a
    | mixed environment - vba & vb, then import because your cls and bas can be
    | used by both [and should be!]. Having them compiled into an inaccessable
    | dvb is not very advantageous when you go to do something in full vb. Or
    use
    | a third option which is compile them to a dll and add refs when you need
    to
    | - assumng you have full vb.
    |
    | Just my $0.02 to stir up the silt!
    |
    | -- Mike
    | ___________________________
    | Mike Tuersley
    | CADalyst's CAD Clinic
    | Rand IMAGINiT Technologies
    | ___________________________
    | the trick is to realize that there is no spoon...
     
    Matt W, Sep 7, 2004
    #20
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.