Declare a variable in Block Scope using VB.NET
This article helps you understanding the declaration of variable in block scope.
Variable declaration is a great new way to make your
application performance better like a new feature Block level scope
declaration in this you can declare the variable for entire procedures when all
you need is a counter in a block. The advantage of using block scoped variables
is that they go out of scope once your code exists the block of code in
For A = 1 To 5
N = N + A
Dim J As
For J = 1 To 4
For A = 1
b = b + A
In this article you can see how to declare block scope
variable and like the output you saw b retains its value between executions of
the inner loop.