|
-
Apr 12th, 2011, 02:42 PM
#1
Thread Starter
PowerPoster
[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
-
Apr 12th, 2011, 04:54 PM
#2
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
-
Apr 13th, 2011, 11:37 AM
#3
Thread Starter
PowerPoster
Re: insert in array the little value...
 Originally Posted by westconn1
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
....
-
Apr 14th, 2011, 05:03 AM
#4
Re: insert in array the little value...
vb Code:
Dim xarr() As String, y As Integer
ReDim xarr(UBound(myarr))
xarr(0) = Left(myarr(0), 19)
For i = 1 To UBound(myarr)
myarr(i) = Left(myarr(i), 19)
If DateDiff("d", xarr(y), myarr(i)) > 0 Then
y = y + 1
xarr(y) = myarr(i)
End If
Next
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|