hi,
Well, I still can't figure this out... I understand that I need to loop my
array, and that finding the upper and lower boundaries of the 'count' within
my array is a clever way to ensure that I loop the correct number of times
without causing an error, but I'm still not getting the results that I want.
Can you give us an example of an array, which gives you the wrong result?
Private Sub Form_Current()
Dim Count As Long 'long could be substituted with integer? Yes.
Dim Dimensions() As String 'this is a string because the statement
"36X42X36 is an array
No. It is an array of strings, because the input is a string. This array
could also be an array of Long, as long as all values are numbers.
Dim MaxDimension As Long 'long could be substituted with integer?
Dim MaxDimensionValue As Long 'long could be substituted with integer?
Dim Length As Integer
Dim dimension1 As Long 'long could be substituted with integer?
Yup, yup, yup, but no need to.
Dimensions = Split([Size 1], "X") 'this simply makes the function easier
to manage
Is [Size 1] a field?
MaxDimension = -1
MaxDimensionValue = -1
For Count = LBound(Dimensions()) To UBound(Dimensions()) 'okay, once
you've determined the lower and upper boundaries, the loop starts by assuming
that the array "36X24X36" is null because there can be no "Dimensions(-1),
right?
The Split function generates arrays from 0 to UpperBoundary, but an
array in VB(A) can start with any Integer. -3 to +3 is also a valid range.
If MaxDimensionValue < Dimensions(Count) Then 'and this is because
an actual number is greater than null?
Yes. You also found my typo.
Me.Length = Count 'shouldn't this be "Me.Length=Dimensions(Count)?
In my original code, i store the index (MaxDimension) and the value
(MaxDimensionValue).
End If
Next Count 'go on to next part of the array
mfG
--> stefan <--