It's better "practice" to dim them at the top. It makes it easier for other programmers to read through your code. They know all your variables that you are using, and with your comments (which everyone does effectively) they know what the variables will contain. <BR><BR>As far as performace, it doesn't really make a difference. From what I've heard, VBScript just looks through all your code when it starts to execute and allocates all the memory for every variable dimmed before it even starts executing your code. That's why you can dim a variable in a loop and it doesn't throw a "you dimmed your variable again, you lazy programmer" error.
Local variables for SUBs, FUNCTIONs, and CLASSes should be only at the top of the Sub/Function/Class.<BR><BR>Or not even then. Just make sure that they *are* declared (DIMed) inside the Sub/Function/Class.<BR><BR>
VBScript moves all the DIM statements *logically* to the beginning during the *COMPILE* phase. So the declarations *are* at the "top" by the time it starts executing the compiled code, and would be even if the execution per se were never started.<BR><BR>Yes, VBS *is* a compiler, despite what you may have heard.<BR><BR>