This is for a mutual fund project
So basically the program reads in records from a text file.
The user should select what report they wanna run from a list box.
Then they’ll type the %’s they wanna use in the report in the text boxes. The reports use LINQ to pull the right records.
The information should then be displayed in a data grid view control
My problem is only the headers appear after the user runs it and not sure why
Would appreciate any feedback
So basically the program reads in records from a text file.
The user should select what report they wanna run from a list box.
Then they’ll type the %’s they wanna use in the report in the text boxes. The reports use LINQ to pull the right records.
The information should then be displayed in a data grid view control
My problem is only the headers appear after the user runs it and not sure why
Would appreciate any feedback
Code
Public Class frmMutualFunds
'Create structure to contain mutual fund data
Structure MutualFunds
Dim symbol As String
Dim description As String
Dim totalReturnThreeMonth As Double
Dim totalReturnSixMonth As Double
Dim oneYearAverageAnnualReturn As Double
Dim threeYearAverageAnnualReturn As Double
Dim fiveYearAverageAnnualReturn As Double
Dim tenYearAverageAnnualReturn As Double
Dim totalReturnYTD As Double
Dim averageAnnualReturnSinceInception As Double
End Structure
'Create array to hold data as it's read
Dim readData(1000) As MutualFunds '1000 records read in from csv file
'On form load event
Private Sub FrmMutualFunds_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Get a count of array elements
Dim fundsCount As Integer
'Place contents of Results (2).csv into readData array
Dim line As String
Dim data(fundsCount) As String
Dim mutualFundData() As String = IO.File.ReadAllLines("Results (2).csv")
'Iterate for each category of data
'Skip mutualFundData(0) to avoid header text
For i As Integer = 1 To fundsCount - 1
line = mutualFundData(i) 'Each line of data from Results (2).csv
data = line.Split(","c) 'Splits each line of data at the comma
'Replace "", --, and % in each record as required
For replaceChar As Integer = 1 To data.Count - 1
data(replaceChar) = data(replaceChar).Replace("""", "").Replace("%", "").Replace("--", "0").Trim()
Next
readData(i).symbol = data(0) 'Read in symbol from data array index 0
readData(i).description = data(1) 'Read in description from data array index 1
'Read items in from data array
'Convert data from string to double
readData(i).totalReturnThreeMonth = CDbl(data(2))
readData(i).totalReturnSixMonth = CDbl(data(3))
readData(i).oneYearAverageAnnualReturn = CDbl(data(4))
readData(i).threeYearAverageAnnualReturn = CDbl(data(5))
readData(i).fiveYearAverageAnnualReturn = CDbl(data(6))
readData(i).tenYearAverageAnnualReturn = CDbl(data(7))
readData(i).totalReturnYTD = CDbl(data(8))
readData(i).averageAnnualReturnSinceInception = CDbl(data(9))
Next
'Don't show datagridview
dgvResults.Visible = False
'Displays number of funds to inform user funds have been read into program
fundsCount = mutualFundData.Count - 1
MessageBox.Show(fundsCount & " funds have been read.")
End Sub
'Runs queries based on user selection from listbox
Private Sub btnRunReport_Click(sender As Object, e As EventArgs) Handles btnRunReport.Click
'Display datagridview when user runs queries
dgvResults.Visible = True
'Remove blank cell at start of rows
dgvResults.RowHeadersVisible = False
'Run query based on user selection from list of reports
Select Case lstQueries.SelectedIndex
Case = 0
'Pull records where average annual reaturn since inception is greater than user supplied percentage
Dim sinceInceptionQuery = From currentReport In readData
Where currentReport.averageAnnualReturnSinceInception > Double.Parse(txtPercentageOne.Text)
Order By currentReport.averageAnnualReturnSinceInception Ascending
Select currentReport.symbol, currentReport.description, currentReport.totalReturnThreeMonth,
currentReport.totalReturnSixMonth, currentReport.totalReturnYTD, currentReport.averageAnnualReturnSinceInception
'Populate datagridview with results of query
dgvResults.DataSource = sinceInceptionQuery.ToList()
dgvResults.CurrentCell = Nothing
Case = 1
'Display total return YTD over user supplied percentage
Dim totalYTDQuery = From currentReport In readData
Where currentReport.totalReturnYTD > Double.Parse(txtPercentageOne.Text)
Order By currentReport.totalReturnYTD Ascending
Select currentReport.symbol, currentReport.description, currentReport.totalReturnThreeMonth,
currentReport.totalReturnSixMonth, currentReport.totalReturnYTD, currentReport.averageAnnualReturnSinceInception
'Populate datagridview with results of query
dgvResults.DataSource = totalYTDQuery.ToList()
dgvResults.CurrentCell = Nothing
Case = 2
'Display records where Total Return (3 Month) is between two user supplied percentages
Dim totalThreeMonthQuery = From currentReport In readData
Where currentReport.totalReturnThreeMonth <= Double.Parse(txtPercentageOne.Text) And currentReport.totalReturnThreeMonth >= Double.Parse(txtPercentageTwo.Text)
Order By currentReport.totalReturnThreeMonth Ascending
Select currentReport.symbol, currentReport.description, currentReport.totalReturnThreeMonth,
currentReport.totalReturnSixMonth, currentReport.totalReturnYTD, currentReport.averageAnnualReturnSinceInception
'Populate datagridview with results of query
dgvResults.DataSource = totalThreeMonthQuery.ToList()
dgvResults.CurrentCell = Nothing
Case = 3
'Display records where Total Return (6 Month) is between two user supplied percentages
Dim totalSixMonthQuery = From currentReport In readData
Where currentReport.totalReturnSixMonth <= Double.Parse(txtPercentageOne.Text) And currentReport.totalReturnThreeMonth >= Double.Parse(txtPercentageTwo.Text)
Order By currentReport.totalReturnSixMonth Ascending
Select currentReport.symbol, currentReport.description, currentReport.totalReturnThreeMonth,
currentReport.totalReturnSixMonth, currentReport.totalReturnYTD, currentReport.averageAnnualReturnSinceInception
'Populate datagridview with results of query
dgvResults.DataSource = totalSixMonthQuery.ToList()
dgvResults.CurrentCell = Nothing
Case = 4
'Display records where Total Return YTD is between two user supplied percentages
Dim totalYTDBetweenQuery = From currentReport In readData
Where currentReport.totalReturnSixMonth <= Double.Parse(txtPercentageOne.Text) And currentReport.totalReturnThreeMonth >= Double.Parse(txtPercentageTwo.Text)
Order By currentReport.totalReturnYTD Ascending
Select currentReport.symbol, currentReport.description, currentReport.totalReturnThreeMonth,
currentReport.totalReturnSixMonth, currentReport.totalReturnYTD, currentReport.averageAnnualReturnSinceInception
'Populate datagridview with results of query
dgvResults.DataSource = totalYTDBetweenQuery.ToList()
dgvResults.CurrentCell = Nothing
End Select
'Clear text boxes
txtPercentageOne.Clear()
txtPercentageTwo.Clear()
End Sub
End Class

![[Image: 3rz8rqA.png]](https://i.imgur.com/3rz8rqA.png)