Question: Private Sub btnDisplay _ Click ( sender As Object, e As EventArgs ) Handles btnDisplay.Click ' Read the states from the file Dim lines (
Private Sub btnDisplayClicksender As Object, e As EventArgs Handles btnDisplay.Click
Read the states from the file
Dim lines As String IOFile.ReadAllLinesUSStatestxt
Create a query to calculate the total land area
Dim totalAreaQuery
From line In lines
Let parts line.Splitc
Let area Integer.Parseparts
Select area
Dim totalArea As Integer totalAreaQuery.Sum
Create a query to order the states by land area and calculate the percentage of the total area
Dim statesQuery
From line In lines
Let parts line.Splitc
Let name parts
Let area Integer.Parseparts
Let percent area totalArea
Order By area Descending
Select name, percent.ToStringF &
Display the results in the data grid view
dgvOutput.DataSource statesQuery.ToList
dgvOutput.ColumnsHeaderText "State"
dgvOutput.ColumnsHeaderText "Percentage of Total Area"
End Sub
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
