Hi group,

I'm attempting to use a variable (i) to read the multiple files within a folder. However this doesn't seem to be working. Can you tell me what I'm doing wrong?

For i = 0 To counter
Dim objReader As New System.IO.StreamReader(getRestranName(i))

    If System.IO.File.Exists(folderName) Then
         Do While objReader.Peek() <> -1
            txtLine = objReader.ReadLine()
            If lineNo = 3 Then
               programName = Trim(Microsoft.VisualBasic.Left(txtLine, 10))

In advance, thanks for your help.

Don

Re: Using a variable to loop through StreamReader 80 80

Please post full codes. seeing a part, it is impossible to say about your problems.

Re: Using a variable to loop through StreamReader 80 80

Shark1, the problem I'm having is that StreamReader isn't reading "getRestranName(i)". My assumption is that the "i" is the problem. But I'm not sure why.

Re: Using a variable to loop through StreamReader 80 80

Shark1, I found the issue. I changed (folderName) to (getRestranName(i)). That solved it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.