Use a different varaiable in the using block:
I think you have the code like this:
Dim i as integer
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("c:\myvbastext\listoffilesandpaths.txt")
MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
MyReader.Delimiters = New String() {","}
Dim currentRow As String()
While Not MyReader.EndOfData
currentRow = MyReader.ReadFields()
i += 1
Nicknam(i) = currentRow(0)
NameOfFile(i) = currentRow(1)
PathOfFile(i) = currentRow(2)
ExtensionOfFile(i) = currentRow(3)
LengthOfRecords(i) = currentRow(4)
End While
End Using
So you can do like this:
Dim i as integer
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("c:\myvbastext\listoffilesandpaths.txt")
Dim j as integer = 0
MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
MyReader.Delimiters = New String() {","}
Dim currentRow As String()
While Not MyReader.EndOfData
currentRow = MyReader.ReadFields()
j += 1
Nicknam(i) = currentRow(0)
NameOfFile(i) = currentRow(1)
PathOfFile(i) = currentRow(2)
ExtensionOfFile(i) = currentRow(3)
LengthOfRecords(i) = currentRow(4)
End While
End Using
...................
................. 'i' is accessible here as well so 'j' is a seperate variable you are using within 'using' block.
....................
....................
....................
Since variable 'i' is using inside the 'using' block and outside the 'using' block as well so it is hiding the value within the 'using' block.