[RESOLVED] [2005] Nested Loop problem
The Program has two files USpres.txt, and usSenate, the program needs to display all presidents that served in the US.Senate. The problem is fixed with the code below. Thanks
Code:
Public Class frmUSPRES
Dim strUSPres, strUSSenate As String
Private Sub btnCompute_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCompute.Click
Dim sr1 As IO.StreamReader = IO.File.OpenText("uspres.txt")
Do While sr1.Peek <> -1
strUSPres = sr1.ReadLine
Dim sr2 As IO.StreamReader = IO.File.OpenText("ussenate.txt")
Do While sr2.Peek <> -1
strUSSenate = sr2.ReadLine
If strUSPres = strUSSenate Then
strUSPres = strUSSenate
lstOutput.Items.Add(strUSPres)
End If
Loop
Loop
Re: [2005] Nested Loop problem
This would read 2 more lines:
vb Code:
If sr1.ReadLine = sr2.ReadLine Then
What you probably want is:
vb Code:
If strUSPres = strUSSenate Then