Having issues with my program, I'm able to get all the data to pull into the grid and into the correct columns / rows. However, my LINQ Query is wrong I believe and it's not making the 3rd column divide properly and insert the correct data. My results: https://gyazo.com/0f307a10dff4c015a361708ecd53c0e9, Correct Result: https://gyazo.com/99e9915bf4ee4e4aa3fb7f2144da1f94. What can I change in my code to change that from a 0 to the correct percentage? Appreciate all responses! Also an example from the text file it is pulling from is this "American Express,AXP,NYSE,Consumer finance,90.73,93.04,5.56,1.01"
Public Class frmDow
Structure stock
Dim company As String
Dim symbol As String
Dim exchange As String
Dim industry As String
Dim price2013 As Double
Dim price2014 As Double
Dim earningsPerShare As Double
Dim dividend As Double
End Structure
Private Sub btnDetermine_Click(sender As Object, e As EventArgs) Handles btnDetermine.Click
Dim inputData() As String = IO.File.ReadAllLines("DOW2014.txt")
Dim stockData(29) As stock
Dim line, data() As String
Dim yield As Double
For i As Integer = 0 To (inputData.Length - 1)
line = inputData(i)
data = line.Split(","c)
stockData(i).company = data(0)
stockData(i).symbol = data(1)
stockData(i).price2014 = data(5)
stockData(i).dividend = data(7)
Next
Dim stockQuery = From stock In stockData
Where yield = data(5) / data(7)
Order By yield Descending
Select stock
For Each stockName In stockQuery
dgvResults.DataSource = stockData
Next
For Each s As stock In stockData
dgvResults.Rows.Add(s.company, s.symbol, yield)
Next
End Sub
End Class
stocktype (which should be named "Stock" either way) should be a class. I'd suggest changing that and seeing if your issue goes away because some issues can be caused by people not properly understanding the implications of using value types.