1 2 0 我试过使用两个阵列......我正在使用图表,但想法是一样的..我试图分离元素,但我不能解决。我是stuct ..任何例子或任何东西都会有所帮助.. thanx提前 Hi, I am working on arrays and I have a problem.I am trying to calculate the difference between data point,Xi, and its predecessor,Xi-1. For example each element in an array or list needs to be subtracted with the previous element. Series 1248333422..Required output 124500120I have tried to use two arrays ...I am using charts but the idea is the same..I tried to seperate the elements but I cant work out. I am stuct.. any example or anything would help.. thanx in advance For i = 0 To Chart1.Series("series1").Points.Count - 1 temp = Chart1.Series("series1").Points(i).YValues xArray(i) = temp(0) ListBox1.Items.Add(xArray(i).ToString()) Next For i = 1 To Chart1.Series("series1").Points.Count - 1 temp = Chart1.Series("series1").Points(i).YValues yArray(i) = temp(0) - temp(i) ListBox2.Items.Add(yArray(i).ToString()) i += 1 Next 提前致谢.. 干杯Thanks in advance..Cheers推荐答案 我不确定 temp 或代码示例中的 ListBox 表示此解决方案对您的问题无效,但以下代码将初始化 arrayA 与您的第一个系列,然后计算 arrayB ,其中包含您想要的结果集。 I''m not sure if temp or the ListBoxs 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 IntegerFor i As Integer = 1 To arrayA.Length - 1 arrayB(i - 1) = Math.Abs(arrayA(i) - arrayA(i - 1))Next 我在计算过程中添加了一个 Math.Abs 调用,因为你需要的输出集合不包含任何底片。I added a Math.Abs call during the calculation as your required output set doesn''t contain any negatives. 这篇关于减去Array vb.net的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 14:08