Rabu, 15 April 2015

Re: [ExcelVBA] Auto-populate a cell based on several other values

 

> Styles vary so much.
Oooh boy!! Or in my case... girl!

> "g" when a global variable is defined in a separate "globals" module
At least you have some sort of naming convention.. minimalist though it is!   :-)

IMHO ... Wormy or not and even if it has been discussed torn apart and put together dissected zillions of times it still bears looking at. 

FOr example... just to put the the cat out there... Arguably the greatest coding innovation ever has been indentation!

My personal preferred format is....

No Comments before the procedure declaration line
Comments directly below the procedure declaration
Space Line
Dims
Space Line
Code
A comment line of stars
End of procedure line

With...
No Multiple single lines with colons.
No end of line comments.
No If statements on a single line.
All Booleans to say If Boolean = True/False Then rather than If Boolean Then.
All groups of comment lines preceded by a space line.
Comment line directly followed by the code they comment.
All dims together
Indent of two spaces
Use continuations a lot to try and keep all of the code visible in the standard VBE code window.


LIsa










To: ExcelVBA <ExcelVBA@yahoogroups.com>
Sent: Mon, Apr 13, 2015 5:25 am
Subject: Re: [ExcelVBA] Auto-populate a cell based on several other values



Oops - I've probably opened a can of worms.  :-)  My thinking was around coding techniques, rather than styles.
 
Coding style discussions are fun, of course.  Styles vary so much.  For instance, you use prefixes (sub, fnc, lng, etc) - I never do (except for a "g" when a global variable is defined in a separate "globals" module). 

Regards, Dave S
 
----- Original Message -----
Sent: Monday, April 13, 2015 5:13 AM
Subject: Re: [ExcelVBA] Auto-populate a cell based on several other values

post the code and ask for coding style suggestions
Actually a great idea!!!
Everyone has different styles so this would be a terrific "excersize" for the group to chip in!

Example.... I use a naming convention for entities of my own which is...
Sub procedures always preceeded bur lowercase "sub" and starting with a capital after that.
ex... subInitialize()

Function procedures likewise but with "fnc" instead of sub.

I include a type and a scope in variable prefixes....
Dim lnglN as Long... lng = long l = local.

The single letter l can be p=parameter m=module level g=global

I also format my code in a particular manner. If people are interested I'd be happy to share.

Any other offers?? Anyone use a personal set of "rules"? What are they?




I'd also be very interested to know how adding comments solved your probbie Duncan?

Lisa


-----Original Message-----
From: 'David Smart' smartware.consulting@gmail.com [ExcelVBA] <ExcelVBA@yahoogroups.com>
To: ExcelVBA <ExcelVBA@yahoogroups.com>
Sent: Sat, Apr 11, 2015 1:37 am
Subject: Re: [ExcelVBA] Auto-populate a cell based on several other values



Glad you got it working.
If you'd like "improvement" commentary, by all means post the code and ask for coding style suggestions.

Regards, Dave S
 
----- Original Message -----
Sent: Friday, April 10, 2015 10:54 PM
Subject: Re: [ExcelVBA] Auto-populate a cell based on several other values

Guys, many thanks for the help, tips & pointers.
After commenting the code, it became clear what it should have been. I now have it populating as it should!
Still looking at it to see if there's anything that can be improved.
Once again, cheers.
Duncan
On 8 Apr 2015 19:49, "Green 1z@compuserve.com [ExcelVBA]" < ExcelVBA@yahoogroups.com> wrote:
 
No sorrys ness Duncan... It *seems* like an interesting problem.

And don't forget that it's poss to upload a file for the group!

Lisa


__._,_.___

Posted by: Green <1z@compuserve.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (13)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Poskan Komentar