Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Correct Indenting (A2k)

    I was wondering if some-one would explain on how to implement the correct indent procedure.
    The following code from Northwind follows this.

    Is there any set parameters to follow when writing code ?
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Correct Indenting (A2k)

    There is no single rule for indentation that is followed by all programmers. If you browse the Internet, you will find different conventions. However, they vary only in details; the overall picture is mostly the same.

    You can decide on the number of spaces you want to indent yourself; many people use 4, I myself use 2, but that is entirely a matter of personal preference. You can set the number in Tools/Options... in the Visual Basic Editor. (Make sure you have AutoIndent checked)

    If you select a block of code, you can indent it by typing Tab, and unindent it by typing Shift+Tab.

    The basic idea of indentation is to indent everything between statements that mark the beginning and end of a unit of code, for instance between Sub and End Sub, and between If and End If. After each beginning statement, press Enter and type Tab to indent. After each intermediate statement, just type Enter. Before typing the ending statement, type Backspace to unindent one level.

    I've seen different conventions for the Select ... End Select block: some people use

    Select Case lngVar
    Case 1
    ' Code for case 1
    Case 2
    ' Code for case 2
    Case Else
    ' Code for all other cases
    End Select

    but others use

    Select Case lngVar
    Case 1
    ' Code for case 1
    Case 2
    ' Code for case 2
    Case Else
    ' Code for all other cases
    End Select

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    Thanks Hans for the info.

    I was showing some-one some of my codes to which he threw his arms up in dispair with my Indentation.
    I usually like to follow your first example, which looks easy on the eye to me when I'm recapping.

    If there is no set format to follow, I'll settle with my current way.

    Regards
    Dave

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    Excellent
    thanks

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Correct Indenting (A2k)

    I follow the second example Hans provided because I indent anything that is subordinate to the beginning and ending of a block of code. Since the Case statements are contained within and are subordinate to the Select Case-End Select block, I find it easier to read them when they are indented.
    Charlotte

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    Thanks for all thoughts on this item of conversation.
    It just go's to show, the variety of topics we can indulge in.
    Whether just making a button do something, or a minor topic for information purposes as this one is.

    I downloaded the indent utility and correctly formatted all my project in a matter of seconds.
    Thanks all

  7. #7
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    To make this thread just a bit longer <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    You can have a look at the RVBA Coding Conventions at http://www.xoc.net/standards/rvbacc.asp

    This is a set of standard that Greg Reddick has put together. I don't agree with everything he says, but it's a great starting place.

    He is also the author of the RVBA Naming Conventions (http://www.xoc.net/standards/rvbanc.asp) which seems to be the defacto standard for most of the Access developers that I know.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Correct Indenting (A2k)

    Not for me. I use the Leszynski naming conventions. Leszynski and Reddick originally published a naming convention together and only parted ways much later. I learned the original and stuck with the Leszynski version by preference. I don't like the 4-char tags that Reddick uses for things like booleans. I prefer a standard 3-character tag across the board.
    Charlotte

  9. #9
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    Yes Charlotte, but you're not like MOST Access Developers that I know <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15> <img src=/S/duck.gif border=0 alt=duck width=23 height=23>
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  10. #10
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Correct Indenting (A2k)

    That's very true - I only know one or two that could hold a candle to Charlotte. As to naming conventions, I too tend to stick to the Leszynski version more than the Reddick, but occasionally make up my own variations. (Part of that might be because I met him (Stan that is) many years ago and was impressed <img src=/S/bow.gif border=0 alt=bow width=15 height=15>).
    Wendell

  11. #11
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    I guess, since you guys are telling me that you use Leszynski's version, could you point me to a copy of it?

    I use RVBA (well a modified version to keep the prefixes at 3 chars) for 2 reasons,

    1) It's what's in the ADH
    2) It's the only one that I could find at the time I was looking <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    I'd be interested in seeing what the difference between L&R's versions are. I propbably won't change, since it's SO ingrained now, I even use it when I'm writing PHP code <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    I even use it when I write "throw-away" code
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  12. #12
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

  13. #13
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Correct Indenting (A2k)

    Thanks Rupert.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  14. #14
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Correct Indenting (A2k)

    <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15>
    If Lounger = carbonnb Then
    <img src=/S/bash.gif border=0 alt=bash width=35 height=39> <img src=/S/bif.gif border=0 alt=bif width=70 height=28> <img src=/S/hosed.gif border=0 alt=hosed width=73 height=24>
    End If
    Charlotte

  15. #15
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Correct Indenting (A2k)

    See if you can track down a copy of his book, Access 97 Expert Solutions, published by Que. It's one of the best books on Access development ever. The details may go out of date somewhat because there are later versions of Access, but the framework is what makes it such a great book. I've never met Stan face to face, but we had some correspondence years ago and I too was impressed.
    Charlotte

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •