Hello,
I have a one-dimensional array that has one number per element. I also have a variable number, var. I need to take the number of elements from the first array that equals the var and put it into a second array with commas between the numbers. I would also like to have a title element in the second array.
This is how my first array looks:
50
216
459
56
2168
12
589
92
This is how I would like my new array to look: (var = 2)
Title
50,216
459,56
2168,12
589,92
This code I'm using right now to try and do this is:
Dim UnsortedNumArray() As String = Array.CreateInstance(GetType(String), Length - Var)
Array.Copy(UnsortedArray, Var, UnsortedNumArray, 0, Length - Var)
Dim NumArray As Array = Array.CreateInstance(GetType(String), UnsortedNumArray.Length)
Dim SpaceArray As String = String.Join(" ", UnsortedNumArray)
Dim ListNumArray() As String = SpaceArray.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries)
Array.Copy(ListNumArray, 0, NumArray, 0, ListNumArray.Length)
Dim ListArray As String = String.Join(",", ListNumArray)
Dim ListVarArray() As String = ListArray.Split(",")
But it just gives me what I started with before that. I did try to use this code for awhile:
For x = 0 To UnsortedNumArray.Length
If (UnsortedNumArray(x), " ").Length < Var Then
Add(UnsortedNumArray(x + 1))
Else
(UnsortedNumArray(x), " ").Length >= Var
End If
Next
But It worked even less; it crashed the debug.
How would I go about doing this?