I am working on a bot which scrapes a list and assigns them into their own rows in a data table.
As you can see, the values have year dates at the end and I want to essentially take the value with the largest date year and disregard the rest. Of course, we can get these years with row(0).ToString.Split(" "c).Last.
My question is: how do I filter these results to take the one with the largest year? I want to then assign it to its own string variable. I’m quite new to this, so it is a bit alien to me aha.
Assuming that you would require the whole cell value which has the Highest Year, then you could try the below Query :
value = DT.AsEnumerable.OrderByDescending(Function(x)Cint(If(Split(x(0).ToString).Last.Trim.IsNumeric,Split(x(0).ToString).Last.Trim,"0"))).First.Item(0).ToString
Here, value is variable of type String and DT is your Input datatable.
Let us know if this is not the expected output.
what is this assign actually doing and will I need to do more after? - This assign will give you the largest year value from the x number of rows in your DT as per your problem statement.