Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help writing the Visual Basic code for this problem. World Series Champions

ID: 3780286 • Letter: N

Question

Need help writing the Visual Basic code for this problem. World Series Champions In the Chap9 folder of the student sample programs, you will find the following files:

-Teams.txt---This file contains a list of several Major League baseball teams in alphabetical order. Each team listed in the file has won the World Series at least once. -WorldSeriesWinners.txt---This file contains a chronological list of the World Series' winning teams from 1903 through 2012. (The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2012. Note that the World Series was not played in 1904 or 1994.)

Create and application that displays the contents of the Teams.txt file in a ListBox control. When the user selects a team in the ListBox, the application should display the number of times that team has won the World Series in the time period from 1903 through 2012. TIP: Read the contents of the

WorldSeriesWinners.txt file into a List or an array. When the user selects a team, an algorithm should step through the list or array counting the number of times the selected team appears.

Teams.txt: Anaheim Angels, Arizona Diamonbacks, Atlanta Braves, Baltimore Orioles, Boston Americans, Boston Braves, Boston Red Socks, Brooklyn Dodgers, Chicago Cubs, Chicago White Sox, Cincinnati Reds, Cleveland Indians, Detroit Tigers, Florida Marlins, Kansas City Royals, Los Angeles Dodgers, Milwaukee Braves, Minnesota Twins, New York Giants, New York Mets, New York Yankees, Oakland Athletics, Philadelphia Athletics, Philadelphia Phillies, Pittsburgh Pirates, San Francisco Giants, St. Louis Cardinals, Toronto Blue Jays, Washington Senators

WorldSeriesWinners.txt: Boston Americans, New York Giants, Chicago White Sox, Chicago Cubs, Chicago Cubs, Pittsburgh Pirates, Philadelphia Athletics, Philadelphia Athletics, Boston Red Sox, Philadelphia Athletics, Boston Braves, Boston Red Sox, Boston Red Sox, Chicago Red Sox, Boston Red Sox, Cincinnati Reds, Cleveland Indians, New York Giants, NEw York Giants, New York Yankees, Washington Senators, Pittsburgh Pirates, St. Louis Cardinals, New York Yankees, New York Yankees, Philadelphia Athletics, Philadelphia Athletics, St. Louis Cardinals, New York Yankees, New York Giants, St. Louis Cardinals, Detroit Tigers, New York Yankees, New York Yankees, New York Yankees, New York Yankees, Cincinnati Reds, New York Yankees, St. Louis Cardinals, New York Yankees, St. Louis Cardinals, Detroit Tigers, St. Louis Cardinals, New York Yankees, Cleveland Indians, New York Yankees, New York Yankees, New York Yankees, New York Yankees, New York Yankees, New York Giants, Brooklyn Dodgers, New York Yankees, Milwaukee Braves, New York Yankees, Los Angeles Dodgers, Pittsburgh Pirates, New York Yankees, New York Yankees, Los Angeles Dodgers, St. Louis Cardinals, Los Angeles Dodgers, Baltimore Orioles, St. Louis Cardinals, Detroit Tigers, New York Mets, Baltimore Orioles, Pittsburgh Pirates, Oakland Athletics, Oakland Athletics, Oakland Athletics, Cincinnati Reds, Cincinnati Reds, New York Yankees, New York Yankees, Pittsburgh Pirates, Philadelphia Phillies, Los Angeles Dodgers, St. Louis Cardinals, Baltimore Orioles, Detroit Tigers, Kansas City Royals, New York Mets, Minnesota Twins, Los Angeles Dodgers, Oakland Athletics, Cincinnati Reds, Minnesota Twins, Toronto Blue Jays, Toronto Blue Jays, Atlanta Braves, New York Yankees, Florida Marlins, New York Yankees, New York Yankees, New York Yankees, Arizona Diamondbacks, Anaheim Angels, Florida Marlins, Boston Red Sox, Chicago White Sox, St. Louis Cardinals, Boston Red Sox, Philadelphia Phillies, New York Yankees, San Francisco Giants, St. Louis Cardinals, San Francisco Giants

Explanation / Answer

Imports System.Linq
Imports System.Net

Public Class Form1
Dim Lines() As String
Dim separator = {", "}
Dim Source As String
Dim Target As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (Target = "") Then
MessageBox.Show("Select League baseball teams from ListBox")
Exit Sub
End If

Dim separator = {", "}
Dim words = (From line As String In IO.File.ReadLines("C:UsersbcDesktopWorldSeriesWinners.txt")

'Enter your file path here for WorldSeriesWinners
From word In line.Split(separator, StringSplitOptions.RemoveEmptyEntries)
Where word = Target).Count
MessageBox.Show("League baseball teams won : " & words & " times")
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Target = ListBox1.SelectedItem.ToString()

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim wc As New WebClient
Source = wc.DownloadString("C:UsersROHIDesktopTeams.txt") 'Enter your file path here for Teams
Lines = Source.Split(separator, StringSplitOptions.None)
For Each s As String In Lines
ListBox1.Items.Add(s)
Next
End Sub
End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote