Results 1 to 3 of 3

Thread: Date Compare

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    1

    Date Compare

    Hi! I am new to Visual Basic and i have a problem and new to the forum.
    The problem that i have right now is that i don't really know how to compare two dates.
    What i am actually trying to do is to compare the Date Today with vbSunday, vbMonday etc using if. But something goes wrong. As for an example:

    Code:
    If Date.Today.Day = vbSunday Then
    {
    
    }

    How can i solve it? Any ideas?

    */Sorry for my english/*

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Date Compare

    Welcome to VBForums

    Thread moved from the 'VB6 and Earlier' forum to the 'VB.Net' (VB2002 and later) forum

  3. #3
    Member
    Join Date
    Dec 2006
    Location
    Derby, UK
    Posts
    58

    Re: Date Compare

    Hi Blaze.

    If you want to do something based on the day of the week (according to the system) I'd suggest using Select Case rather than an If Statement. Something like:

    vb Code:
    1. Select Case Date.Today.DayOfWeek
    2.   Case DayOfWeek.Monday
    3.     'Code Here
    4.   Case DayOfWeek.Tuesday
    5.     'Code Here
    6. End Select

    Hopefully this will point you in the right direction.

    Chris.

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