Compare filename date to todays date

I am trying to make a personal reminder program.
Compare file names to todays date

I have files that are saved with the files date as the name
the file names are loaded into a listbox
02-20-2015.rtf
02-21-2015.rtf
02-22-2015.rtf
02-20-2016.rtf


 Private Sub lstTasks_Click()
   Dim myDate As Date
        myDate = Len(lstTasks.Text) - 4 'minus extension        
    If myDate = Date Then ' a new task to handle
        Call MsgBox("You have a scheduled task to consider", vbInformation, "Needs attention")
        'call load the rtf file here to richtextbox
    End If
End Sub

this code produces
Debug.Print myDate = 1/9/1900
how can this be fixed ?
isnoend2001Asked:
Who is Participating?
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

pls try

myDate = DateValue(Left(lstTasks.Text, Len(lstTasks.Text) - 4))

Regards
0
 
isnoend2001Author Commented:
Thanks
I have found this:
myDate = CDate(Left$(lstTasks.Text, Len(lstTasks.Text) - 4)) and it also works
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.