DataGridView使用Structures显示文本文件

时间:2016-11-22 01:24:53

标签: vb.net

我的DataGridView没有显示正确结果的问题,下面我将发布我的代码,其中一些已被注释掉,因为我不希望它按降序排序因为我甚至不能让它正确显示。我错过了什么?当我单击我的按钮时,网格会为结果创建正确数量的框,但它们都是空的。文本文件中的一行示例如“美国运通,AXP,纽约证券交易所,消费者金融,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(240) 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 = CDbl(data(5))
        stockData(i).dividend = CDbl(data(7))
    Next

    dgvResults.DataSource = stockData

    ' Dim stockQuery = From stock In stockData
    'Where data(7) / data(5) = yield
    'Order By yield Descending
    'Select Case stock

End Sub
End Class

0 个答案:

没有答案