68 774
Assignments Done
Successfully Done
In January 2019

Answer to Question #61985 in Visual Basic for dsf

Question #61985
Suppose the sequential file ALE.TXT contains the information shown in Table 1.1. Write a program to use the file to produce the Table 1.2 in which the baseball teams are in descending order by the percentage of games won. Note : A batting average can be displayed in standard form with FormatNumber(ave, 3, vbFalse).
Expert's answer
Public Class Form1
Dim ALL As String
Dim currentrow As String()
Dim currentField As String
Dim I, j As Integer

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
I = 0
While DataGridView1.Rows.Count <> 0
End While

MsgBox("Please, choose file with data", , "data")
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ALL = OpenFileDialog1.FileName
Exit Sub
End If
DataGridView1.ColumnCount = 4
DataGridView1.Columns(0).HeaderText = "Team"
DataGridView1.Columns(1).HeaderText = "Won"
DataGridView1.Columns(2).HeaderText = "Lost"
DataGridView1.Columns(3).HeaderText = "Persentage"
DataGridView1.RowHeadersVisible = False
DataGridView1.AllowUserToAddRows = False
Label1.Text = "American League East"

Using myreader As New Microsoft.VisualBasic.FileIO.TextFieldParser(ALL)
myreader.TextFieldType = FileIO.FieldType.Delimited
I = -1

While Not myreader.EndOfData
currentrow = myreader.ReadFields()
I = I + 1
j = 0
For Each Me.currentField In currentrow
DataGridView1.Rows(I).Cells(j).Value = currentField

j = j + 1


Catch ex As Exception

End Try
End While

End Using

For Me.I = 0 To DataGridView1.Rows.Count - 1
DataGridView1.Rows(I).Cells(3).Value = FormatNumber(CInt(DataGridView1.Rows(I).Cells(1).Value) / (CInt(DataGridView1.Rows(I).Cells(1).Value) + CInt(DataGridView1.Rows(I).Cells(2).Value)), 3, vbFalse)

DataGridView1.Sort(DataGridView1.Columns.Item(3), System.ComponentModel.ListSortDirection.Descending)

End Sub

End Class

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions