Question: Visual Basic Question here. So there's a screenshot of my entire assignment below, and I have it mostly coded. I'm having trouble figuring out how

Visual Basic Question here. So there's a screenshot of my entire assignment below, and I have it mostly coded. I'm having trouble figuring out how to poll the .txt file and get a count by specific line. So for example, this codes it to save either R, D, or I but I cannot figure out how to get it to display a count of each specific party in my txt boxes in the app. Here's the assignment...

Visual Basic Question here. So there's a screenshot of my entire assignment

Here's the interface I've made for this (based on the assignment directions)

below, and I have it mostly coded. I'm having trouble figuring out

For reference, my output boxes are txtDem, txtRep and txtInd

Here's my code so far. It's really a matter of getting the btnDisplay code correct which I'm having the trouble with.

Private Sub btnWrite_Click(sender As Object, e As EventArgs) Handles btnWrite.Click Dim outFile As IO.StreamWriter outFile = IO.File.AppendText("party.txt") outFile.WriteLine(txtParty.Text & txtAge.Text) outFile.Close() txtParty.Text = String.Empty txtAge.Text = String.Empty txtParty.Focus() End Sub

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click ' reads names from a sequential access file ' and displays them in the interface

' declare variables Dim inFile As IO.StreamReader ' clear previous names from the Contestants box txtParty.Text = String.Empty

' determine whether the file exists If IO.File.Exists("party.txt") = True Then inFile = IO.File.OpenText("party.txt") Else MessageBox.Show("Can't find the file", "party.txt", MessageBoxButtons.OK, MessageBoxIcon.Information) End If

End Sub

Any help with this is appreciated.

During July and August of each year, the Political Awareness Organization (PAO) sends a questionnaire to the voters in its district. The questionnaire asks each voter for his or her political party (Democratic, Republican, or Independent) and age. From the returned questionnaires, the organization's secretary tabulates the number of Democrats, Republicans, and Independents in the district. The secretary wants an application that she can use to save each respondent's information (political party and age) to a sequential access file. The application should also calculate and display the number of voters in each political party. Create a Visual Basic Windows application. Use the following names for the solution and project, respectively: PAO Solution and PAO Project. Save the application in the ClearlyVB20121Chap22 folder. Change the name of the form file on your disk to frmMain.vb. If necessary, change the form's name to frmMain. Create the interface shown in Figure 22-15. The Party text box should accept only the Backspace key and the letters D, d, R, r, I, or i. The Age text box should accept only numbers and the Backspace key. Code the Click event procedures for the Write to File and Display Totals buttons. Save the solution and then start and test the application. Close the Code Editor window and then close the solution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!