Results 1 to 2 of 2

Thread: [02/03] Comparing values

  1. #1

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    [02/03] Comparing values

    I am doing the month calendar objects on one form and i save the date to the registry. I do this by creating the subkey and in that key I create a value and I pass the date from the month calendar control by doing monthCalendar.SelectionStart. This puts the date value into the registry.

    On the other form I read the registry key and set it to a string. I would like to compare that date to the date modified (or IO.File.GetLastWriteDate) of certain files. The date that is sent to the registry from the month calendar object is something like 7/22/2006 12:00:00 AM. How can I just compare the two dates?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] Comparing values

    You compare Date objects using the Date.Compare method. Obviously you have to convert the string retrieved from the registry into a Date object first. This means that you should decide on a specific format and use it to convert the original date to a string in the first place:
    VB Code:
    1. Dim regValue As String = myDate.ToString("d/MM/yyyy")
    and then use that same format when convert from a string back to a date:
    VB Code:
    1. Dim myDate As Date = Date.ParseExact(regValue, "d/MM/yyyy", Nothing)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width