View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Fernando Fernando is offline
external usenet poster
 
Posts: 21
Default error comparing dates


Hi,
Error when comparing a range of dates, returns false instead of true.

code:
dim hrMax as date
Do While CDate(lstMax.List(lstMax.ListCount - 1)) < hrMax
.....
loop

explanation:
lstMax (listbox control) has an array of of times ("11:00 AM", "12:00 AM",
"1:00 PM", etc), in the loop, the camparison goes like this:

Do While CDate("10:00 AM") < "10:00:00 AM" -- result: true
Do While CDate("11:00 AM") < "10:00:00 AM" -- result: false
Do While CDate("12:00 AM") < "10:00:00 AM" -- result: false
Do While CDate("1:00 PM") < "10:00:00 AM" -- result: false

why does the 1st returns true?.
when I debug step by step, I can see that the it should return false

This file manages data files, and this error is only present on very few files

thanks for your help