Where do you put your variables ?



  • I was reviewing an Excel sheet which had a macro which was slow.

    I went into the code and noticed no variable declarations. I wonder how many errors I would get if I turned Option Explicit. (In VB6 en VBA declarations of variables is not required, they are all variants).

    I got zero errors back. So I thought perhaps he has declared them at the top of a module. So I selected the variable and went to the definition. I jumped to a module called "modOptionExplicit" which has all the variables of all 20 modules.

    And of course all procedures didn't use any parameters. I stopped reviewing it because this was too genious for me.

    CE



  • Betreft: Where do you put your variables ?

    No example of this ingenious work? Oh, come on... There are students here wanting to learn from the genious ideas of others.



  • @Katja Bergman said:

    No example of this ingenious work? Oh, come
    on... There are students here wanting to learn from the genious ideas
    of others.




    Wonder what betreft means...



    Anyway...



    Generally I put my variables as close to where they are needed. If I
    need a variable that store some general state of something, I'll put it
    as a member of that something. I rarely have any globals at all in any
    of my programs.



  • @Mike R said:

    Wonder what betreft means...

     

    Considering the context, it probably means 'regarding' ...



  • @redtetrahedron said:

    Considering the context, it probably means 'regarding' ...





    Hmm. I just looked over the thread and read the titles of the posts,
    again. Katja replied using that word, instead of Re: was  that
    intentional?





    The Edit control on this board seems to still have problems. Eveyr time
    Itype a space, it doesnt show until I start typing another character
    and it s driving me nuts.



  • It's Dutch for 'regarding'. Usually shortened to Betr: by Outlook I prefer Re:

    Drak



  • Betreft: Re: Betreft: Where do you put your variables ?

    Yeah, well... Sorry but this forum allowed me to read it in the Dutch
    language and ever since it's putting 'Betreft:' in front of every
    reply. Can't help this without complaining about the dumbness of this
    forum not recognising that 'Re:' and 'Betreft:' are just the same...



    Or dumb to allow multiple languages to be used in this forum. Still,
    makes me wonder what it would look like if I had chosen 'Chinese' as
    language... [:D]



  • Give it a try, and us all a good laugh [;)]

    Drak



  • Obviously, in this day and age of object orientation, you put everything inside a single singleton called GlobalVariables.


Log in to reply