度に関する情報を datagridview に表示するコードがあります。このプログラムは機能しますが、配列を使用してこの情報を表示する必要があることがわかりました。データ テーブルに表示する方法を理解したら、それは非常に簡単でしたが、別の方法で行う必要があります。アドバイスをお願いします!
Dim array As New DataTable
Dim array2 As New DataTable
Dim array3 As New DataTable
Private Sub btnQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnQuit.Click
Me.Close()
End Sub
Private Sub btnDegrees_Click(sender As System.Object, e As System.EventArgs) Handles btnDegrees.Click
array.Clear()
Dim column1 As DataColumn = New DataColumn("Field of Study")
column1.DataType = System.Type.GetType("System.String")
Dim column2 As DataColumn = New DataColumn("1981")
column2.DataType = System.Type.GetType("System.String")
Dim column3 As DataColumn = New DataColumn("2006")
column3.DataType = System.Type.GetType("System.String")
array.Clear()
array.Columns.Add(column1)
array.Columns.Add(column2)
array.Columns.Add(column3)
array.Rows.Add("Business", "200,521", "318,042")
array.Rows.Add("Computer and info. science", "15,121", "47,480")
array.Rows.Add("Education", "108,074", "107,238")
array.Rows.Add("Engineering", "63,642", "67,045")
array.Rows.Add("Social sciences and history", "100,513", "161,485")
Me.dgvStudies.DataSource = array
End Sub
Private Sub btnChanges_Click(sender As System.Object, e As System.EventArgs) Handles btnChanges.Click
array2.Clear()
Dim column4 As DataColumn = New DataColumn("Field of Study")
column4.DataType = System.Type.GetType("System.String")
Dim column5 As DataColumn = New DataColumn("Change (1981-2006)")
column5.DataType = System.Type.GetType("System.String")
array2.Columns.Add(column4)
array2.Columns.Add(column5)
''Display array two containing percentage changes''
array2.Rows.Add("Computer and info. science", "214.0%")
array2.Rows.Add("Social sciences and history", "60.7%")
array2.Rows.Add("Business", "58.6%")
array2.Rows.Add("Engineering", "5.3%")
array2.Rows.Add("Education", "-0.8%")
dgvStudies.DataSource = array2
End Sub
Private Sub btnHistogram_Click(sender As System.Object, e As System.EventArgs) Handles btnHistogram.Click
array3.Clear()
Dim column6 As DataColumn = New DataColumn("Field of Study")
column6.DataType = System.Type.GetType("System.String")
Dim column7 As DataColumn = New DataColumn("")
column7.DataType = System.Type.GetType("System.String")
Dim column8 As DataColumn = New DataColumn("Degrees in 2006")
column8.DataType = System.Type.GetType("System.String")
array3.Clear()
array3.Columns.Add(column6)
array3.Columns.Add(column7)
array3.Columns.Add(column8)
array3.Rows.Add("Computer and info. science", "*****", "47,480")
array3.Rows.Add("Engineering", "*******", "67,045")
array3.Rows.Add("Education", "***********", "107,238")
array3.Rows.Add("Social sciences and history", "****************", "161,485")
array3.Rows.Add("Business", "********************************", "67,045")
dgvStudies.DataSource = array3
End Sub
End Class