If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > array sortimg (data and time array)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-12, 23:38
manuavaran manuavaran is offline
Registered User
 
Join Date: Dec 2011
Posts: 27
Red face array sortimg (data and time array)

i need to sort some arrays in the basis of date and time , i wrote some code.but it does not work properly.please help me

Quote:

For i = 1 to Rec_count

For j = i+1 to Rec_count

if(CaldTime( i ) < CaldTime( j )) then

temp = CaldTime(j)
CaldTime( j ) = CaldTime( i )
CaldTime( i ) = temp

End If
Next
Next
Reply With Quote
  #2 (permalink)  
Old 01-11-12, 05:52
manuavaran manuavaran is offline
Registered User
 
Join Date: Dec 2011
Posts: 27
Smile

I solved this one on my own. Probably far from the most elegant, but this is what I did:

For i = 1 to Rec_count
For j = i to Rec_count
if CaldTime( i ) <> "" and CaldTime( j ) <> "" then

if( DateDiff("s",DateValue(CaldTime( i )) &" "& (FormatDateTime(CaldTime(i ),4)), DateValue(CaldTime( j)) &" "& (FormatDateTime(CaldTime(j ),4))) > 0) then

temp = CaldTime(j)
CaldTime( j ) = CaldTime( i )
CaldTime( i ) = temp

End If

End If

Next
Next
Reply With Quote
  #3 (permalink)  
Old 01-11-12, 10:29
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I wrote something in Access a long time ago that does something like this.

Ordering a Listbox where RowSourceType = "Value List"

Hope this helps
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 01-11-12, 22:42
manuavaran manuavaran is offline
Registered User
 
Join Date: Dec 2011
Posts: 27
Thanku dear gvee
the link was very useful
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On