Results 1 to 3 of 3

Thread: Array Help

  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •