Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Function vs. Subroutine

Discussion in 'Information Technology' started by PeterM, Nov 8, 2005.

  1. PeterM

    PeterM
    Expand Collapse
    Guest

    Is it better for performance to have a set of code that is called from all
    forms be created in a module as a function or subroutine? Every one of our
    100+ forms calls this code to set the forecolor, backcolor, etc appearance
    for each form.

    Thanks in advance for your help!
     
  2. Loading...


  3. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    I don't think there'll be a noticable difference between the two.

    If you create a function (even if you don't have the function return a
    value), you can set the form's Open property to the name of the function,
    rather than having to have a Sub Form_Open for the form. On the other hand,
    I never do that...

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "PeterM" <PeterM@discussions.microsoft.com> wrote in message
    news:3C6E4DFF-AD16-4F9B-BE3C-12E4422A046F@microsoft.com...
    > Is it better for performance to have a set of code that is called from all
    > forms be created in a module as a function or subroutine? Every one of

    our
    > 100+ forms calls this code to set the forecolor, backcolor, etc appearance
    > for each form.
    >
    > Thanks in advance for your help!
     
  4. John Vinson

    John Vinson
    Expand Collapse
    Guest

    On Mon, 7 Nov 2005 08:06:05 -0800, PeterM
    <PeterM@discussions.microsoft.com> wrote:

    >Is it better for performance to have a set of code that is called from all
    >forms be created in a module as a function or subroutine? Every one of our
    >100+ forms calls this code to set the forecolor, backcolor, etc appearance
    >for each form.
    >
    >Thanks in advance for your help!


    Performance of a Sub or a Function should make very little if any
    difference. However, a Function is handy in one way - you don't need
    to actually create an [Event Procedure] in each form to call it.
    Instead simply put

    =MyFunction([Form])

    on the form's Open (or other appropriate) event; within the function,
    use

    Public Function MyFunction(frm as Form)

    to pass the identity of the form as an argument.

    Obviously if you already have an Event Procedure, you can simply call
    the function within that procedure.

    John W. Vinson[MVP]
     
  5. Ron Hinds

    Ron Hinds
    Expand Collapse
    Guest

    "PeterM" <PeterM@discussions.microsoft.com> wrote in message
    news:3C6E4DFF-AD16-4F9B-BE3C-12E4422A046F@microsoft.com...
    > Is it better for performance to have a set of code that is called from all
    > forms be created in a module as a function or subroutine? Every one of

    our
    > 100+ forms calls this code to set the forecolor, backcolor, etc appearance
    > for each form.
    >
    > Thanks in advance for your help!


    More important than performance in this case is maintainability. If there is
    a bug in the function, right now you have to make the fix (*if* you remember
    to ;-) in 100+ forms, vs. ONCE if it is modularized!
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page