View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default General tips for good code formatting

Congrats!!!...Check out the below link on coding practices.....(will be useful)

http://blogs.msdn.com/excel/archive/...practices.aspx

Below are some other tips for a starter level....

--As Jim mentioned include lot of comments. I personally include comments
for each variables I declare; I had experiences spending hours to identify
what the variable do..

intRaceCounter 'Number of races
dtStartTime 'Start time of race

--Using data type prefix for variables

lngRow denotes data type Long
varTemp denotes that the variable is of Variant data type
strRaceName denotes that the variable is String variable
arrData denotes that the variable is an Array

User forms with frmStartUp, frmCalculations, frmSettings
Textboxes prefixed with txtStartTime, txtEndTime
Comboboxes with cmbStartTime, cmbEndTime
Command Buttons with cmdSubmit, cmdOK

--Naming of variables..While coding all of us prefer to use short variables
names eg (x,y,c,i are commonly used) but in the long run that will not
help..Name it as below so as to reflect the variable type and the purpose...

strFirstName
dtStartDateTime
dtStopDateTime


If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I finally have my code working. I am trying to tidy it up for several reasons

1) so others can follow it
2) so it will run faster
3) so it is easier/quicker to edit
4) to reduce the risk of typing mistakes

So far I have implemented the option explicit statement and put in some
loops for repetitive code. I have also saved it as a web page and then saved
it back to an xls file to reduce file size (went from 9MB to 5MB). Is there
any risks with doing this.

Is there a website I can look at that outlines basic good practice for code
format.

Thanks again for everybodies input. My scoring program already far exceeds
my expectations of what I was aiming for when I first started. Unfortunately
the time taken to do it was the same.