[RESOLVED] Loop in Loop error
Hey guys, in my project I am trying to have the program write to a richtextbox which gathers data from files using a loop inside of a loop. The program works OK, it finds the files and reads them but the richtextbox should be returning two values but instead its only returning one. Can anyone help me with this is there any errors in my code. Here's the code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim totalFiles As String
Dim filePaths As New System.Text.StringBuilder
Dim fileCount As Integer = 0
For Each file As String In My.Computer.FileSystem.GetFiles(Application.StartupPath & "\files")
fileCount += 1
filePaths.Append(My.Computer.FileSystem.GetName(file) & vbCrLf)
totalFiles = filePaths.ToString()
Next
RichTextBox1.Text = filePaths.ToString()
TextBox1.Text = fileCount
System.IO.File.WriteAllText(Application.StartupPath & "\data\values.txt", filePaths.ToString())
Dim getFiles As IO.StreamReader = New IO.StreamReader(Application.StartupPath & "\data\values.txt")
Dim getLine As String = Nothing
Dim getLineCount As Integer = 0
Do While Not getFiles.EndOfStream
Dim infoFile As String = getFiles.ReadLine()
getFiles.ReadLine()
getLine = getFiles.ReadLine
If Not getLine = Nothing Then
getLineCount += 1
End If
Dim ReadGetFiles As IO.StreamReader = New IO.StreamReader(Application.StartupPath & "\files\" & infoFile)
Dim readgetLine As String = Nothing
Dim readgetLineCount As Integer = 0
Dim lineone As String = Nothing
Dim linetwo As String = Nothing
Dim linethree As String = Nothing
Dim linefour As String = Nothing
Dim linefive As String = Nothing
Dim linesix As String = Nothing
Do While Not ReadGetFiles.EndOfStream
readgetLine = ReadGetFiles.ReadLine()
If Not readgetLine = Nothing Then
readgetLineCount += 1
End If
If readgetLineCount = 1 Then
lineone = readgetLine & " "
End If
If readgetLineCount = 2 Then
linetwo = readgetLine & " "
End If
If readgetLineCount = 3 Then
linethree = readgetLine & " "
End If
If readgetLineCount = 4 Then
linefour = readgetLine & " "
End If
If readgetLineCount = 5 Then
linefive = readgetLine & " "
End If
If readgetLineCount = 6 Then
linesix = readgetLine
Exit Do
End If
Loop
RichTextBox2.Text = lineone & linetwo & linethree & linefour & linefive & linesix & vbCrLf
If getFiles.EndOfStream Then
Exit Do
End If
Loop
End Sub
Any help would be much appreciated and thanks for your patience.