dim in loop

Results 1 to 3 of 3

Thread: dim in loop

  1. #1
    Join Date
    Dec 1969

    Default dim in loop

    dim inside loop doesn&#039;t redim<BR><BR>It seems like the second iteration of a loop containing a DIM shoud generate a re-dim error - but it does not. <BR><BR>Insight?

  2. #2
    Join Date
    Dec 1969

    Default Dont dim in loop

    Dim before (Outside loop)<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default You *CAN'T* DIM in a loop!

    Oh, you can *CODE* the DIM inside the loop, but it doesn&#039;t matter.<BR><BR>VBScript takes *ALL* DIM statements that it finds and automatically moves them to the very front of the page code.<BR><BR>It does this for efficiency, so that all the memory space for declared variables is preallocated during the compile phase.<BR><BR>So feel free to put the DIM inside the loop, but don&#039;t expect it to act any differently than if you put it at the front of the page. Or at the end, for that matter.<BR><BR>[The only exceptions are DIMs that occur inside functions/subs/classes, where they then have "scope" only inside their respective functions/subs/objects.]<BR><BR>

Posting Permissions

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