I am currently working on a project in vb.net that involves inputting lines of delimited information from a txt file, then displaying it on a dataviewgrid, AND calculating percentage change between two of the values.
How can I input all of this data into an array or something similar, so I can input it into a DGV AND still run calculations with it?
dgvDegrees.Rows.Clear()
dgvDegrees.Columns.Clear()
dgvDegrees.ColumnCount = 3
dgvDegrees.Columns(0).Name = "Degree"
dgvDegrees.Columns(1).Name = "1981"
dgvDegrees.Columns(2).Name = "2010"
Using stream As System.IO.FileStream = System.IO.File.OpenRead("degrees.txt")
Using reader As New System.IO.StreamReader(stream)
Dim line As String = reader.ReadLine()
While (line IsNot Nothing)
Dim columns = line.Split(",")
line = reader.ReadLine()
Dim index = Me.dgvDegrees.Rows.Add()
Me.dgvDegrees.Rows(index).SetValues(columns)
End While
End Using
End Using
dgvDegrees.Sort(dgvDegrees.Columns(0), System.ComponentModel.ListSortDirection.Ascending)
This method that I am using now inputs the raw data into a DGV, but I have a seperate button I created to show the percentage differences, and I am a bit confused as to what the most efficient way to input the data but also save it in an array would be; the method I am using now just reads the data and ends.
For a bit more context, here is a sample of the input I am working with
Engineering,13453,34203 Journalism,15328,29392 etc...
The first number is the amount of people that pursued this degree in 1981, and the second in 2010
My goal is to read the data into a DGV (which I already have done), but I cannot figure out how to isolate the numbers so I can calculate the percentage change between the two years. What do I need to do to assign the values to arrays that can be calculated into percentages later to be put in another column of my DGV?