If I have an array that has 400 elements in the X and 8 elements in the Y. How can I split this out in VB.net to have 8 seperate array curves with the 400 elements in X.
Hi, please copy the data into DataTable, then use LinQ to get the data you want. For example:
Dim array As String(,) = {{"Mike", "Amy"}, {"Mary", "Albert"}, {"Mary", "Albert"}, {"Mary", "Albert"}, {"Mary", "Amy"}}
Dim table As New DataTable()
table.Columns.Add("FirstName", GetType(String))
table.Columns.Add("LastName", GetType(String))
Dim i As Integer = 0
Dim str1 As String = ""
Dim str2 As String = ""
For Each item As String In array
If i Mod 2 = 0 Then
str1 = item
i += 1
Else
str2 = item
table.Rows.Add(str1, str2)
i = 0
str1 = ""
str2 = ""
End If
Next
Dim list As EnumerableRowCollection = From rows In table.AsEnumerable() Where rows("LastName") = "Amy" Select rows("FirstName")
Dim list1 As New List(Of String)()
For Each item As String In List
list1.Add(item.ToString())
Next
madpanda
0 Points
1 Post
Arrays
Jun 02, 2012 02:48 PM|LINK
If I have an array that has 400 elements in the X and 8 elements in the Y. How can I split this out in VB.net to have 8 seperate array curves with the 400 elements in X.
Ie 8 of 400 * 1 instead of 400 * 8
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Arrays
Jun 04, 2012 03:10 AM|LINK
Hi, please copy the data into DataTable, then use LinQ to get the data you want. For example:
Dim array As String(,) = {{"Mike", "Amy"}, {"Mary", "Albert"}, {"Mary", "Albert"}, {"Mary", "Albert"}, {"Mary", "Amy"}} Dim table As New DataTable() table.Columns.Add("FirstName", GetType(String)) table.Columns.Add("LastName", GetType(String)) Dim i As Integer = 0 Dim str1 As String = "" Dim str2 As String = "" For Each item As String In array If i Mod 2 = 0 Then str1 = item i += 1 Else str2 = item table.Rows.Add(str1, str2) i = 0 str1 = "" str2 = "" End If Next Dim list As EnumerableRowCollection = From rows In table.AsEnumerable() Where rows("LastName") = "Amy" Select rows("FirstName") Dim list1 As New List(Of String)() For Each item As String In List list1.Add(item.ToString()) NextIf you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework