AddIn – ObjectDev. A Class Building Addin

screen-shot


Introduction:

This whole project began because of my utter loathing for
Visual Basic’s Class Builder utility. I spent long amounts of time creating
COM objects with repetitive coding. I also became interested in VB add-ins. I
then decided to write my own Class Builder utility. I named it ObjectDev because
it helps you develop objects. ObjectDev requires a knowledge of COM both to use
it and to understand its code. I hope you find ObjectDev a useful and
informative tool.

What ObjectDev Does:

ObjectDev allows the user to specify any number of subs,
functions, and properties. If Create Interface is selected, ObjectDev then
generates an interface and an object which implements the interface. If Create
Interface is not selected, then ObjectDev creates an object with no interface.
If Persistable is selected, code is added to the ReadProperties and
WriteProperties functions which enables persistence. If IsDirty is selected, a
property let/get and a boolean is added to the objects. When a property is
changed, the IsDirty boolean changes to True. ObjectDev will cut hours off the
time required to create components for your program.

MGlobals:

When I first began designing ObjectDev, I noticed that if you
show another form, the variables on the original form do not hold their values.
The best way around this problem was to create global variables to hold the
information.

CPrefixes:

Since I wanted ObjectDev to be flexible, I decided to allow
the prefixes on all variables to be changed. Since I allowed this changing, I
needed something to hold the prefixes, and CPrefixes was born. CPrefixes is just
a straightforward object that does nothing but hold data.

CProperty and CPropertyCollection:

In order to store the properties created by the user, I wrote
an object/collection. The properties/functions of CProperty are detailed below.
The collection is self-explanatory.

  • PropName – the name of the property

  • ReturnType – enumeration of the type of the property
    (i.e. string, variant, etc.)

  • Style – specifies if the property is Let/Get, Set/Get,
    Get (an object), or Get

  • RetAsStr – returns a string with the ReturnType spelled
    out (i.e. “string”, “variant”, etc)

  • VarName – returns the name of the property’s variable
    (i.e. ByVal sName as String) if you pass True, then either ByVal or ByRef is
    added on the front

  • ByType – specifies if the property’s variable is passed
    ByRef or ByVal

 

CSubFunction and CSubFunctionCollection:

In order to store the subs/functions created by the user, I
wrote these objects. The properties/functions of CProperty are detailed below.
The collection is self-explanatory.

  • Arguments – holds the arguments collection for this
    sub/function (see the doc on CArgument and CArgumentCollection)

  • IsPrivate – specifies if the sub/function is private or
    public

  • RetAsStr – returns a string with the function return type
    spelled out (i.e. “string”,“variant”, etc.)

  • ReturnType – an enum which specifies the function return
    type

  • SubName -the name of the sub/function which will be
    written in code

 

CArgument and CArgumentCollection:

In order to store the arguments of each subs/function created
by the user, I wrote these objects. The properties/functions of CProperty are
detailed below. The collection is self-explanatory.

  • ArgName – the name of the argument which will be written
    to code

  • ArgOptional – specifies if the argument is optional or
    not

  • ArgType – the type of the argument (i.e. string, variant,
    etc.)

  • ByType – specifies if the argument is passed ByVal or
    ByRef

  • ByTypeAsString – returns “ByVal” or “ByRef”
    depending on what ByType is

  • TypeAsString – returns a string with the argument type
    (i.e. FuncName As String, FuncName As Variant, etc.)

 

Legal Garbage:

I developed this add-in for my personal growth as a Visual
Basic developer. I also feel that programmers should help each other out as much
as possible. Therefore, I really do not care what you do with this code. I would
prefer that you just not compile my code and show everyone this wonderful add-in
you created, but you can. If you improve my code, I would appreciate if you give
me some credit, but you do not have to. Also, if you improve on my code, I would
like you to send your code to me (
pclogic15@hotmail.com).
In short, you can do whatever you want to with my code. You do not have to give
me any compensation or recognition.

Conclusion:

I hope you either learn from ObjectDev, find it useful, or
both. I would appreciate your comments. Also, I would appreciate a quick email
if you find something wrong. Please send all emails to
pclogic15@hotmail.com.


Download Zipped Project File (30k)

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read