Public Class frmColleges

  Structure College
    Dim name As String
    Dim state As String
    Dim yearFounded As Integer
  End Structure

  Dim colleges() As College

  Private Sub frmColleges_Load(ByVal sender As System.Object,
                               ByVal e As System.EventArgs) Handles MyBase.Load
    'Place the data for each college into the array schools
    Dim schools() = IO.File.ReadAllLines("Colleges.txt")
    Dim n As Integer = schools.Count - 1
    ReDim colleges(n)
    Dim data() As String   'hold data for a single college
    For i As Integer = 0 To n
      data = schools(i).Split(","c)
      colleges(i).name = data(0)
      colleges(i).state = data(1)
      colleges(i).yearFounded = CInt(data(2))
    Next
  End Sub

  Private Sub btnDisplay_Click(ByVal sender As System.Object,
                               ByVal e As System.EventArgs) Handles btnDisplay.Click
    'Display the colleges in Colleges.txt located in the given state
    Dim collegeQuery = From col In colleges
                       Where col.state = mtbState.Text.ToUpper
                       Order By col.name Ascending
                       Select col.name, col.yearFounded
    dgvColleges.DataSource = collegeQuery.ToList
    dgvColleges.CurrentCell = Nothing

  End Sub








  'Display the colleges in COLLEGES.TXT located in the given state
  'lstCollege.Items.Clear()
  'Dim collegeQuery = From institution In colleges _
  '                   Where institution.state = mtbState.Text.ToUpper _
  '                   Order By institution.name Ascending _
  '                   Select institution.name, institution.yearFounded
  'Dim collegeQuery = From institution In colleges _
  '                   Let name = institution.name _
  '                   Let st = institution.state _
  '                   Let yr = institution.yearFounded _
  '                   Where st = mtbState.Text.ToUpper _
  '                   Order By name Ascending _
  '                   Select name, yr
  'lstCollege.Items.Clear()
  'For Each col In collegeQuery
  '  lstCollege.Items.Add(col.name & " " & col.yr)
  'Next


  Private Sub dgvColleges_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvColleges.CellContentClick

  End Sub
End Class
