Results 1 to 4 of 4

Thread: Here a dim, There a dim, everywhere a dim, dim

  1. #1

    Thread Starter
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843

    Here a dim, There a dim, everywhere a dim, dim

    Is anyone else having trouble reading code you hacked together, mere days or even hours ago
    because of the obscene amount of Dim statements?
    I'm coming in from VB6.0 and it was very tidy when you put all your dim's a the top of the procedures and functions
    and New'd any objects you might need.

    Now, with vb.net it seems that dimming in the middle and everywhere else is just "what you do".
    You are allowed, even encouraged, to overload your dims with things like
    dim x as objtype = new objtype.overload(blah blah)

    It's one of the bigger hurddles for my small mind to, er, leap over.
    Most of the other stuff is gel-ing nicely, but the idea that I 'dim on the fly' seems blasphemous.


    Not sure if I should chalk this up to progress or if it's a step backwards in the grand scheme of things.

    Course the scheme of things seems to be to make .NET complicated enough so
    that ordinary hacks will have to pay to get a program written for them.
    Merry Christmas

  2. #2
    Member
    Join Date
    Dec 2003
    Posts
    43
    Now, with vb.net it seems that dimming in the middle and everywhere else is just "what you do".
    All other languages use this scheme. So id consider it a step forward. Not to mention OOP,Overloading etc.....Everything is just better.

  3. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045
    You can always put your dim statements at the top.

    One advantage of putting dims for complex functions like file browsers and the like is that it keeps the prerequisites for the function in the same viciinity of the code as the function call, and also, if the function is in a loop that does not get executed, I don't think the resources get allocated for the call. (???) If so, wouldn't that make the code run faster? Just a guess ...
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    As webtest stated it is now considered better to keep your declarations as close to their first use as possible.
    In C# I've noticed that if you declare a variable at the start of a function, and it does not get assigned, maybe because of a loop condition then the compiler returns a warning stating this might happen.

Posting Permissions

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



Click Here to Expand Forum to Full Width