cmdolcet
asked on
Issues with determining Array Length
How to determine a variable length of an array where I am looking for the last two value in the array. Those last two values are always start with "vad" or "rate" but the array length size can be variable.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you show how you're creating the array?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So I am looking at how to discover the values ( DistanceVar,RateVar)
The TempArray is array I am working with but how do I assign the DistanceVar and the RateVar which is always the last two slots in the array.
The TempArray is array I am working with but how do I assign the DistanceVar and the RateVar which is always the last two slots in the array.
If tempArray.Length > 0 Then
Me.ChartVel.ChartAreas(0).AxisX.Minimum = 0
Me.ChartVel.ChartAreas(0).AxisX.Title = "Time"
Me.ChartVel.ChartAreas(0).AxisY.Title = "m/s"
For intloopVel = 0 To tempArray.Length - 2
If intloopVel < 255 Then
Veldata.Add(tempArray(intloopVel))
Veltime.Add(tempArray(intlooptime))
x = Veltime(intloopVel)
x = 0.000001 * x
y = Veldata(intloopVel)
lstVelocityChartReadings.Items.Add(tempArray(intloopVel))
Me.ChartVel.Series(0).Points.AddXY(x, y)
If Veldata(intloopVel) >= PeakPoint Then
PeakPoint = Veldata(intloopVel)
End If
If value = 100 Then
Else
Application.DoEvents()
value = value + 0.5
PrgGraphBar.Value = value
End If
intlooptime = intlooptime + 1
End If
Next
VelErrorChartCounter = 0
PrgGraphBar.Value = 0
DistanceVar = tempArray(?)
RateVar = tempArray(?)
DistanceVar = DistanceVar.Remove(0, 6)
RateVar = RateVar.Remove(0, 7)
lblPeakValue.Text = PeakPoint
lblVelDistance.Text = DistanceVar
lblVelocityRateData.Text = RateVar
EndIf
Quite simply:
-saige-
DistanceVar = tempArray(tempArray.Length - 2)
RateVar = tempArray(tempArray.Length - 1)
This of course assumes that tempArray.Length - 2 and tempArray.Length - 1 are both valid indices.-saige-
ASKER
It_Sage,
What do you mean?
What do you mean?
Say tempArray has a length of 1, tempArray.Length - 1 = 0, where as tempArray.Length - 2 = -1. -1 is an invalid index.
-saige-
-saige-
ASKER
I need the actual value in the slot and not the index.