• Array Help

    Author
    Topic
    #464684

    Hi all,

    I am trying count down an Array, I can’t figure out how get all the items in the array to fill a listbox, my problem is I keep missing the last item in the array, this is just a snippet of what I have with in a module.

    All of the items with in the array are there, i think the problem is with the -1, but I am not sure, can some one shine some light on this?

    Thanks,
    Darryl.

    Option Explicit

    Do Until i = 10
    Set os = Sheets(1).Cells(i + 281, k) ‘PLATE
    zzzzz = VBA.Format(CDate(ddate), “dd-mmm-yy”)
    If HasComment(os) Then
    A = VBA.Mid(os.Comment.Text, 1, 256)
    arrparts = Split(A, “+”)
    For j = LBound(arrparts) To UBound(arrparts) – 1
    ReDim Preserve Plate(iii)
    Plate(iii) = arrparts(j)
    iii = iii + 1
    Next j
    End If
    i = i + 1
    Loop
    iii = 0
    i = 0
    ‘If validateArray(Plate) = True Then
    For j = LBound(Plate) To UBound(Plate) – 1
    If InStr(1, Plate(j), “First”, vbTextCompare) > 0 Then
    Mail_Form.LB_Plate.AddItem VBA.Left(Plate(j), InStr(1, Plate(j), “First”, vbTextCompare) – 3)
    End If
    End If

    Viewing 1 reply thread
    Author
    Replies
    • #1190530

      You should probably use

      For j = LBound(Plate) To UBound(Plate)

      instead of

      For j = LBound(Plate) To UBound(Plate) – 1

      and perhaps also

      For j = LBound(arrparts) To UBound(arrparts)

      instead of

      For j = LBound(arrparts) To UBound(arrparts) – 1

      but that depends on the meaning of arrparts.

    • #1190541

      Thanks Hans,

      I’ll take your advice on removing the -1, from the (plate), because I am using the split function on the Arrparts, it has produces ” ” elements in the Array, so I’ll keep the -1 when filling the array.

      Thanks,
      Darryl.

    Viewing 1 reply thread
    Reply To: Array Help

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: