Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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...

image text in transcribed

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

=+ What are the information and consultation requirements?

Answered: 1 week ago