In terms of memory allocation and performance, the first snippet contains a superfluous assignment of the empty string to
q before entering the loop.
From a performance point of view this should not be of any concern whatsoever, but from a best software engineering practices point of view, the second snippet is definitely preferable, since the variable is declared within the scope in which it is used.
Readability and maintainability are far more important than performance in the vast majority of scenarios out there, and statistically speaking, the chances that your business is an exception to this rule are slim.
My recommendation would be to go ahead and build your software product properly, and if it turns out that there is a performance problem, (most probably there won't be any,) then throw the profiler at it to see precisely where the problem is, and once you have found the problem spots, then go ahead and improve only those spots that need improvement.
Being concerned about the performance of every tiny little thing all over the place, and tweaking and hacking things proactively here and there just in order to squeeze clock cycles blindly, without having any idea whether these clock cycles are actually needed, is no way of writing software.
Clock cycles will always be wasted. Even if you abandoned Visual Basic in favour of Assembly Language you would soon discover that it is impossible not to waste clock cycles. The point is to only worry about clock cycles when you have a very good reason to do so, and in the vast majority of cases, you don't have any. Poorly performing software performs poorly mostly due to algorithmic problems, not due to programmers being careless with clock cycles.
I don't know about Visual Basic, but in most decent programming languages the compiler is capable of warning you if you attempt to use a variable which has not been initialized yet, but this ability of the compiler is compromised by the very prevalent and very misguided practice of initializing variables to nonsensical defaults like
Dim q as String = "" above. So, I would recommend avoiding
Dim q as String = "" like the plague.