|
-
Oct 10th, 2002, 10:48 AM
#1
Thread Starter
Lively Member
Loading an Array
I would like to load an Array with values (the code below assigns a value to the s array(objData.s(1,0), then assigns this value to "XValue" which I want loaded into the array as separate points. I then want to view the high value & the low value of these 25 points within the array. How 2?
Dim MeasurePoint As Single
Dim XValue As Single
Dim MyArray(1 To 25)
For MeasurePoint = 1 To 25
MLString "VT 1,0,0,-1,0,0,CO"
XValue = objData.s(1, 0)
MyArray(MeasurePoint) = XValue
Next MeasurePoint
Dim HighRetrieval As Single
Dim LowRetrieval As Single
HighRetrieval = UBound(MyArray)
LowRetrieval = LBound(MyArray)
-
Oct 10th, 2002, 11:17 AM
#2
Thread Starter
Lively Member
I don't know if I explained myself well, but the code as it currently is returns a value of "25" for the high and "1" for the low. I assume that my points are not loaded.
-
Oct 10th, 2002, 11:45 AM
#3
Addicted Member
I could be way off on this, but doesn't UBound just return the index of the last number in the array? So if you've got 31 items declared Array(1 to 31) the UBound would return 31, not the actual item that's sittin in position 31
-
Oct 10th, 2002, 12:25 PM
#4
Thread Starter
Lively Member
that's what I'm seeing. So how do get the high value in the array?
-
Oct 10th, 2002, 12:49 PM
#5
Addicted Member
Just for clarity, do you want the highest value in the array or the last item? For instance, if 25 is the highest value in an array, but 10 is the last item, UBound would refer to the Index of 10.
-
Oct 10th, 2002, 01:15 PM
#6
Thread Starter
Lively Member
I want the highest value, the 25, not the highest index (10).
-
Oct 10th, 2002, 01:25 PM
#7
Addicted Member
Ok, here's what you need to do. Something like this:
VB Code:
Dim HighRetrieval as Integer
HighRetrieval = MyArray(0)
'sets the value of high retrieval to the first item
For i = 1 to UBound(MyArray)
If MyArray(i) > HighRetrieval Then
HighRetrieval = MyArray(i)
End If
Next
HighRetrieval should hold the highest number in the array. Same technique for LowRetrieval only with <.
-
Oct 10th, 2002, 01:43 PM
#8
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|