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

Visual Basic- How would I edit this code to make use of a Split method? Public C

ID: 3806586 • Letter: V

Question

Visual Basic- How would I edit this code to make use of a Split method?

Public Class frmFrequencies
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDisplay.Click

Dim frequency(4) As Integer
Dim fmtStr As String = "{0,-12} {1,-9:N0}"
Dim strDigits() As String = IO.File.ReadAllLines("Scores.txt")

For i As Integer = 1 To strDigits.Count - 1
frequency(CInt(Int(strDigits(i) / 10))) += 1
Next
lstOutput.Items.Add(String.Format(fmtStr, "Interval", "Frequency"))
For i As Integer = 0 To 4
lstOutput.Items.Add(String.Format(fmtStr, CStr(i * 10) & " to " & CStr((i + 1) * 10 - 1), frequency(i)))
Next
End Sub

End Class

------------------

The text file "Scores.txt" contains the following:

38

47

38

26

42

48

33

29

40

37

38

43

28

39

46

35

28

32

29

40

41

48

49

18

48

20

26

39

44

8

The output must match this:

a a Frequencies Display Frequencies Interval Frequency 0 to 9 10 to 19 20 to 29 30 to 39 40 to 49 12

Explanation / Answer

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click 'I am declaring my variables Dim Org As String Dim adate As String Dim ddate As String Dim days As String 'declaring variable for my date calculation Dim date1 As DateTime = CDate(mtxtBox1.Text) Dim date2 As DateTime = CDate(mtxtBox2.Text) Dim numdays As TimeSpan = date2.Subtract(date1) Dim numdays2 As Integer = numdays.Days 'Declaring my variables for the amounts input Dim afare As Integer Dim lodge As Integer Dim taxi As Integer Dim meals As Integer Dim total As Integer Dim MaE As Integer 'Assigning values to the variables Org = txtOrg.Text.ToUpper adate = mtxtBox1.Text ddate = mtxtBox2.Text days = adate & " - " & ddate & " : " & " " & txtLocation.Text.ToUpper 'assigning valuables with format currency afare = CInt(FormatCurrency(txtAFare.Text)) lodge = CInt(FormatCurrency(txtLodging.Text)) taxi = CInt(FormatCurrency(txtTaxi.Text)) meals = CInt(FormatCurrency(txtMandE.Text)) total = CInt(FormatCurrency(afare + lodge + taxi)) MaE = CInt(FormatCurrency(meals / 2)) 'assigning value to show the total of expenses and 50% of meals and entertainment total2 = "TOTAL DEDUCTIBLE EXPENSES:" & " " & FormatCurrency(total + MaE) 'Adding the items to my first list box 'I put spaces in "" to format the listbox I didn't know exactly how to use fmtstring lstReports.Items.Add("") lstReports.Items.Add("BUSINESS TRAVEL EXPENSES:") lstReports.Items.Add(" ") lstReports.Items.Add("TRIP TO ATTEND MEETING OF :") lstReports.Items.Add("") lstReports.Items.Add(Org) lstReports.Items.Add(days) lstReports.Items.Add("NUMBER OF DAYS:" & " " & numdays2) lstReports.Items.Add("") lstReports.Items.Add("EXPENSES:") lstReports.Items.Add(" ") lstReports.Items.Add("AIR FARE : " & " " & FormatCurrency(afare)) lstReports.Items.Add("LODGING : " & " " & FormatCurrency(lodge)) lstReports.Items.Add("TAXI FARE : " & " " & FormatCurrency(taxi)) lstReports.Items.Add("TOTAL : " & " " & FormatCurrency(total)) lstReports.Items.Add("") lstReports.Items.Add("MEALS AND ENTERTAINMENT EXPENSE:") lstReports.Items.Add(" " & FormatCurrency(meals)) lstReports.Items.Add("") lstReports.Items.Add(total2) lstReports.Items.Add("") lstReports.Items.Add(" ") 'This is to count how many trip submits I have and this is shown in the second list box when summary button is pressed trips += 1 End Sub