Visual Basic错误

时间:2013-11-05 17:58:14

标签: vb.net visual-studio

我在第15行收到错误,'预期声明结束'

我做错了什么?即使是班级神童也说这应该有效,原因如下:

Public Class Form1

Private Sub btnShow_Click(sender As Object, e As EventArgs) Handles btnShow.Click
    Dim states() As String = IO.File.ReadAllLines("USStates.txt")  ' makes array
    Dim data = From state In states
    Let line = state.Split(","c)
    Let Name = line(0)
    Let stateAb = line(1)
    Let area = CInt(line(2))
    Let census = CDbl(line(3))
    Order By Name Ascending
    ' query
    Select name,stateAb,area,census

*在此处获得错误***

    dgvOut.DataSource = data.ToList
    dgvOut.CurrentCell = Nothing
    dgvOut.Columns("Name").HeaderText = "State Name"
    dgvOut.Columns("ststeAb").HeaderText = "Abbreviation"
    dgvOut.Columns("area").HeaderText = "Area In Sq. Miles"
    dgvOut.Columns("census").HeaderText = "Population"
End Sub
End Class

2 个答案:

答案 0 :(得分:2)

删除' query - 您无法在那里发表评论。

答案 1 :(得分:1)

尝试使用续行:

Dim data = From state In states _
Let line = state.Split(","c) _
Let Name = line(0) _
Let stateAb = line(1) _
Let area = CInt(line(2)) _
Let census = CDbl(line(3)) _
Order By Name Ascending _
Select name, stateAb, area, census