Solved

Compare filename date to todays date

Posted on 2015-02-22
2
56 Views
Last Modified: 2015-02-22
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 ?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40625133
Hi,

pls try

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

Regards
0
 

Author Closing Comment

by:isnoend2001
ID: 40625138
Thanks
I have found this:
myDate = CDate(Left$(lstTasks.Text, Len(lstTasks.Text) - 4)) and it also works
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question