Do you ever Dim i as Int and use it over and over again, just to realize that you forgot to set i = 0 before one of your loops? Well fear no more, you can create a variable named i without diming it and it only lives inside a narrow scope. Check this out:
For i As Integer = 0 To 10
Next
You can even Dim a variable inside a IF Block (or any other block) and it is only available in the scope of that block.
If True = True Then
Dim i As Integer = 0
i = i + 1
End If
If True = True Then
Dim i As Integer = 0
i = i + 1
End If
No comments:
Post a Comment