Function getmaxy(ptarr(), y As Double) As Variant'获得具人相同Y坐标的最大点 If UBound(ptarr) = 0 Then max = ptarr(i) For i = 0 To UBound(ptarr) For j = 0 To UBound(ptarr) If ptarr(i)(1) = y And ptarr(j)(1) = y Then If ptarr(i)(0) > ptarr(j)(0) Then max = ptarr(i) End If End If Next j Next i getmaxy = max End Function 运行以后发现此函数有问题 而下面的没有 Function gomin(ptarr(), y As Double) As Variant '获得具人桢同Y坐标的最小点
For i = 0 To UBound(ptarr) For j = 0 To UBound(ptarr) If ptarr(i)(1) = y And ptarr(j)(1) = y Then If ptarr(i)(0) > ptarr(j)(0) Then min = ptarr(j) End If End If Next j Next i gomin = min End Function 请问错在哪?
如果点组中有Y坐标的点只有一点,该强何处理? |