Efficent VBA Code - Variable & Memory Questions

Discussion in 'AutoCAD' started by Oberer, Jan 28, 2005.

  1. Oberer

    Oberer Guest

    I'm asking for some verification & clarification on a couple of codiing questions...

    1) I've always heard that it's more efficent to to process as few "."'s as possible. In other words, set a referenced to ThisDrawing.Blocks if using a for/each loop.

    Example:
    For each oBlock in ThisDrawing.Blocks vs
    next
    set Blocks = ThisDrawing.Blocks
    For each oBlock in Blocks
    next

    However, I see plenty of code (and no suggestions to "tighten it up") that make liberal use of extended hiearchies.

    2)"Releasing Variables" - I've always taken the time to Set ObjectVar = Nothing at the end. i rarely see this, and i know it's supposed to happen by default. is this a waste of time?
     
    Oberer, Jan 28, 2005
    #1
  2. Let's face it: if you have to squeeze every last drop of performance out
    of your application, you won't be using VB or VBA.
    Mechanically speaking, yes. However, the benefit is clarity and that's
    hardly a waste of time.
     
    Frank Oquendo, Jan 29, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.