I'm not sure if
temp
or the
ListBox
s in your code example mean that this solution isn't valid for your problem, but the following code will initialise
arrayA
with your first series and then calculate
arrayB
which contains your desired result set.
Dim arrayA As Integer() = {1, 2, 4, 8, 3, 3, 3, 4, 2, 2}
Dim arrayB(arrayA.Length - 2) As Integer
For i As Integer = 1 To arrayA.Length - 1
arrayB(i - 1) = Math.Abs(arrayA(i) - arrayA(i - 1))
Next
I added a
Math.Abs
call during the calculation as your required output set doesn't contain any negatives.