FlexGrid Sorting Question....

If my column is text and represents time-of-day:
ie:     7:00am    11:30am    4:50pm    etc.
This sort command:
MSFlex2.Sort = flexSortStringAscending
puts 4:50pm in front of 7:00am because of the numerics.
What command will sort my grid according to time-of-day?
rbendAsked:
Who is Participating?
 
PePiCommented:
create another column with 0 width (.ColWidth(c) = 0; where c is the column); then based on your column with the time, copy the value to the 0 width column and format with FORMAT(CDate(.textmatrix(.row, 1)), "HH:mm:ss"). therefore, assuming that the time column is 1 and your 0 width column (or your sort column) is 2 then:

MSFlex2.textmatrix(.row, 2) = Format(MSFlex2.textmatrix(.row,1),"HH:mm:ss")
MSFlex2.colsel = 2      'this will set the column with the military time format as your sorting column
MSFlex2.Sort = flexSortStringAscending


HTH!



0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.