none
Scaling VBA modules RRS feed

  • Question

  • Hi,

    what is a reasonable number of lines in a module ?

    what is preferable long or many modules ?

    what is your experience ?

    Those issues are to me a doubt since I'vd start doing VBA code...

    João

     

    Wednesday, November 23, 2011 12:38 PM

Answers

  • The limit is the amount of lines a programmer can easily scan thru productively. So use every opportunity to create new modules. So one for all code interfacing with SQL Server, another for all code working with Exce and so on.

    It takes more time and money to maintain code tehn it ever does to write it in the first place. Structure make it easier and cheaper to maintain.


    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management
    Thursday, November 24, 2011 7:58 AM

All replies

  • Hi João,

     

    I have read that limits are like this (in below thread):

    http://bytes.com/topic/access/answers/810804-code-module-size-limits

     

    So if you are not near those limits you are still ok.

    I haven't the need to code that large amount of lines in the past.

    You can call different Functions also within a Fuction, so no need to re-write the same code for example.

     

    But if you want to count the lines, check this thread by Allen Browne:

    http://allenbrowne.com/vba-CountLines.html

     


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    Wednesday, November 23, 2011 7:10 PM
    Moderator
  • In article <243bbeb8-5919-4a1f-b0de-91531c731554
    @communitybridge.codeplex.com>, =?iso-8859-2?B?
    Sm9hbyBTaW1wbGljaW8gUm9kcmlndWVz?= says...
    >
    > Hi,
    >
    > what is a reasonable number of lines in a module ?
    >
    > what is preferable long or many modules ?
    >
    > what is your experience ?
    >
    > Those issues are to me a doubt since I'vd start doing VBA code...
    >
    > Joao
    >
    I guess this is subjective,
    depending on preferences of developer or the team.
     
    Both too large and too many modules
    are the opposite extremes to avoid.
     
    It is like if you have rectangles with given area
    with too narrow or too wide one side.
    It is the best to keep it square-like.
     
    I use set of several modules covering separate topics of project,
    + one of top level public procedures,
    + often also option private module
       for project wide only sub/func/const/var definitions.
     
    If modules go to large for my easy overview,
    I divide that hierarchically.
     
     
     
     
    --
    Poutnik
     
    Thursday, November 24, 2011 7:31 AM
  • The limit is the amount of lines a programmer can easily scan thru productively. So use every opportunity to create new modules. So one for all code interfacing with SQL Server, another for all code working with Exce and so on.

    It takes more time and money to maintain code tehn it ever does to write it in the first place. Structure make it easier and cheaper to maintain.


    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management
    Thursday, November 24, 2011 7:58 AM
  • Thank you all for your replies.

    João

    Monday, November 28, 2011 10:44 AM