PC Review


Reply
Thread Tools Rate Thread

Class versus Another Way, Wbk and Sheet Custom Data Needs

 
 
Neal Zimm
Guest
Posts: n/a
 
      4th Jun 2010
Hi All,
What are the most important factors I should consider to answer the
following question.

Should I convert a pretty large amount of WORKING vba code to use a
class for workbooks and the sheets within them so I can set up properties
for
workbooks and sheets that are germaine to my application ?

I know this is more of a consulting question, than how to code it, but I'm
at a key point in time in the development of a prettly large add-in and now
is the time to continue as I have been, or rewrite code.

Two examples: Sheet, Threshold and Inventory Count. (there are about 5
workbook "properties" and 15 for a sheet.)

Users will work on selected sheets converting data from an old application
to the new. Once a Count of inventory-type items reaches a varying threshold
the sheet is 'production' ready. Threshold is based on geographic area(a
value in a cell). Once Count is >= the threshhold, the values do not change
all that much.

Background:
- Am self taught in vba, (I've programmed in other languages, used Walken-
bach's book, ask lots of questions on this board) but never learned about
classes as it seemed not applicable at the time. In hindsight, probably a big
mistake.

- If workbooks had a .CustomProperties property(which I just found out
about) like sheets, I would go with that solution. It's a contender for my
sheets solution. The 'fact finding' code is in the example procs below.

- None of my addin's needs are hardware related, (Walkenbach's class
example in his book is toggling the NumLock key.)

- In kind of 'pseudo code', what I currently do at workbook open event and
sheet activation event, (as well as at other times) uXXXXX are Public Type
records holding the App's "custom properties" as field values.

workbook example
Call WbkFacts(Wbk, uWbkPropsAy()) 'fact array for open wbks, (#) is same
'as workbooks collection item #

sheet example
uWsFacts = WsFactsGetF(ActiveSheet) 'function makes sheet-facts record

- The calls above are also used in a "gateway" macro that lets/prevents a
user menu selected task from running against the 'wrong' workbook or the
'wrong' sheet. (e.g. Very few of the addin's procs will run when the
activeworkbook is named Like "*Personal*.xls" or "*Personal*.xlsm"

Factors I've thought about: (back to my question of what are others?)
- Maybe it's time to learn about classes, sooner or later I will need to.
- Public Type records are easily maintainable, add a field, some new code.
- Don't know how "non standard" my solution is if someone else has to
change the code.
- Since true properties stay with the object I wouldn't have to run the
fact gathering procs nearly as often. (Although they run pretty quickly)

Looking forward to your advice,
Thanks,
Neal Z.
--
Neal Z
 
Reply With Quote
 
 
 
 
Neal Zimm
Guest
Posts: n/a
 
      5th Jun 2010

Thanks Joel,
Being able to re-use classes that I would set up in other projects will
probably be one of the major deciding factors. With the current application,
that is not an easy call.

Thanks again,
--
Neal Z


"joel" wrote:

>
> Writing code using classes has an advantage when you create a new
> application you can simply copy the class from one workbook to another
> very easily. It is also nice when somebody else modifies you macros the
> code is orgainize in a style that will make it easier for other people
> to understand your code.
>
> You have to decide if it is worth the time of re-writing a macro that
> is already working. When you gererate a new macro you have to look at
> macro you already have writen and see if you are going to re-use older
> code or generate new code using a different style.
>
> If your older code is hard to understand because you used non-standard
> code then it may be worth the effot to change the code. It really
> depends on how well you code is documented and how often you are going
> to modify the code in the future.
>
>
> --
> joel
> ------------------------------------------------------------------------
> joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=207233
>
> http://www.thecodecage.com/forumz
>
> .
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import data from another sheet that matches to a class list? gmac70 Microsoft Excel Worksheet Functions 4 5th Oct 2009 02:37 AM
bind data to gridview using custom data class? =?Utf-8?B?dmluZWV0YmF0dGE=?= Microsoft ADO .NET 5 17th Oct 2006 11:23 PM
how to bind Data to Grid view with custom data class. =?Utf-8?B?dmluZWV0YmF0dGE=?= Microsoft ADO .NET 0 16th Oct 2006 07:06 AM
Overhead base class versus derived class method invocation question Microsoft C# .NET 1 20th Dec 2005 02:29 PM
Binding to custom data class Bill Youngman Microsoft ADO .NET 1 5th Jul 2004 12:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:22 AM.