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.
I hate to be one of these posters that requires hand-holding, but until I
master some of these basic skills, it's my only option. So, here goes...
This is the code that Stefan was kind enough to come up with for me, plus my
notes indicating my understanding of it:
Private Sub Form_Current()
Dim Count As Long 'long could be substituted with integer?
Dim Dimensions() As String 'this is a string because the statement
"36X42X36 is an array
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?
Dimensions = Split([Size 1], "X") 'this simply makes the function easier
to manage
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?
If MaxDimensionValue < Dimensions(Count) Then 'and this is because
an actual number is greater than null?
Me.Length = Count 'shouldn't this be "Me.Length=Dimensions(Count)?
End If
Next Count 'go on to next part of the array
End Sub
Well, obviously, there are nuances here that I am missing, but if I
understand the basic concept, please let me know, as that is at least a place
to start. I am attempting to define the field 'Length' as the longest
dimension in the array. The array comes from a text field in a table called
[Size 1]. As a check, I've called the field [Size 1] to be displayed as is.
I've also called the dimensions within that field as [dimension1],
[dimension2], and [dimension3] so I can see what I get. Finally, I've called
the field [Length] to be the longest of the three dimensions. The split
function works fine. When there are all three dimensions in the array, the
code works fine, but when there are only two, the last record with a third
dimension 'sticks' and shows up with the other two. Another problem I'm
having is that sometimes there are spaces between the values and sometimes
there aren't: "36X42X36" or "36 X 42 X 36". I've tried using Val() with
some success, but I'm not sure if I am causing myself problems by doing so.
Sometimes, there is also bad data that needs to be noted. For instance,
someone has input text instead of the standard array format. Basically, I
would like to split the array into the appropriate dimensions and when there
isn't one, use a zero. If the data is bad, note it.
Sorry to whine. Thanks for all your help.