Asked by Wally
I need to write a program to solve for the following: Suppose that the file USPRES.txt contains the names fo the frist 43 United States presidents and the file USSENATE.TXT contains the names of all former and present US Senators. Write a program with nested loops that uses these files to display the names of the presidents who served in the Senate. This is for VB 2008 and here is what I have so far:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filename As String
Dim president As String = ""
Dim sr1 As IO.StreamReader = IO.File.OpenText("C:Files.txt")
filename = sr1.ReadLine
Dim sr2 As IO.StreamReader = IO.File.OpenText(filename)
Do While (sr2.Peek <> -1)
president = sr2.ReadLine
Loop
ListBox1.Items.Add(president)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filename As String
Dim president As String = ""
Dim sr1 As IO.StreamReader = IO.File.OpenText("C:Files.txt")
filename = sr1.ReadLine
Dim sr2 As IO.StreamReader = IO.File.OpenText(filename)
Do While (sr2.Peek <> -1)
president = sr2.ReadLine
Loop
ListBox1.Items.Add(president)
End Sub
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.