Results 1 to 4 of 4

Thread: [RESOLVED] insert in array the little value...

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,941

    Resolved [RESOLVED] insert in array the little value...

    With this code i loop item and fill array.
    But during the loop of value i can have alway a pair of date similar:

    01/01/2011 19.00.14
    and
    01/01/2011 05.00.11
    ....
    02/01/2011 19.00.27
    and
    02/01/2011 05.00.02

    i need to compare the two pair of dates and insert into array only the most little date from the pair... in this case fill the array with:

    01/01/2011 05.00.11
    02/01/2011 05.00.02

    Code:
    For Each olItm In olFld.Items
            If InStr(olItm.Subject, "test") Then
                TEST = olItm.ReceivedTime
                ReDim Preserve ARRAY_DATE(I)
                ARRAY_DATE(I) = TEST
                I = I + 1
            End If
        Next
    note:
    TEST is the var filled with dates

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: insert in array the little value...

    you could do a sql query on the olfied items, in order by receivedtime, then it would be simple to to loop through the recordset, skipping until the next day value
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,941

    Re: insert in array the little value...

    Quote Originally Posted by westconn1 View Post
    you could do a sql query on the olfied items, in order by receivedtime, then it would be simple to to loop through the recordset, skipping until the next day value
    if is most simple i post my question on other side:

    Admitting i loop the series of value with a for next how to fill combobox items with the value marked with < - Selected

    In effect i need to fill the items oin combo with the dates vale with the oldest time:

    ...
    01/01/2011 05.00.11 <- Selected
    01/01/2011 19.00.14
    01/01/2011 21.21.11
    02/01/2011 05.00.02 <- Selected
    03/01/2011 01.00.03 <- Selected
    03/01/2011 12.17.21
    03/01/2011 18.00.27
    ....

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: insert in array the little value...

    vb Code:
    1. Dim xarr() As String, y As Integer
    2. ReDim xarr(UBound(myarr))
    3. xarr(0) = Left(myarr(0), 19)
    4. For i = 1 To UBound(myarr)
    5.     myarr(i) = Left(myarr(i), 19)
    6.     If DateDiff("d", xarr(y), myarr(i)) > 0 Then
    7.         y = y + 1
    8.         xarr(y) = myarr(i)
    9.     End If
    10. Next
    11. ReDim Preserve xarr(y)  ' resize final array
    i tested this pasting your little table, in post above, into myarr, and had the correct result in xarr
    this assumes that as your example the dates are already in order
    if not you can sort the initial array by date, there are many examples in this forum and code bank for sorting arrays
    note i had to remove the "<-selected" (left 19) or i got i type mismatch in the date function
    ?join(xarr," ~ ")
    01/01/2011 05.00.11 ~ 02/01/2011 05.00.02 ~ 03/01/2011 01.00.03
    Last edited by westconn1; Apr 14th, 2011 at 05:08 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width