dcsimg
Results 1 to 6 of 6

Hybrid View

  1. #1

    Thread Starter
    Registered User
    Join Date
    Mar 2018
    Posts
    3

    Resolved [RESOLVED] Change color of a lable based upon date comparison

    Hey Folks, I am setting up a an employee database and I want to be able to compare the expiry date of the employee's drivers license to the current date. The idea is that if the employee's license is due to expire in the next 30 days it will send an alert to the main calendar (yet to be developed) msg side bar which at this stage will be a label array. it is always the simple things that stump me, i have been playing with this for 2 days, very frustrating for something that should be so simple. Thanks Daz

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,138

    Re: Change color of a lable based upon date comparison

    It isn't clear to me quite what the question is. The general design sounds pretty reasonable, but when you say "send an alert", that could mean several different things, so that might be the issue...except that you say you haven't written that part, yet. Normally, sending an alert might be by raising a custom event that the calendar would then handle. That may be over engineered, though, because it could also just be calling a function on the main calendar, or setting a property, or even letting the main calendar ask for the information.

    Changing the color itself isn't much of a problem, as you just decide whether you change the fore or back color. The fore color is a less obvious change, but can look pretty nice. If you want to bludgeon the user with the fact that something needs to be done, then change the back color, cause nobody will likely miss that.

    So, I guess I'm not sure what you are asking about.
    My usual boring signature: Nothing

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,914

    Re: Change color of a lable based upon date comparison

    I'm with Shaggy, i.e. I don't really understand what you're asking. If it's just how to compare the dates, that's easy, e.g.
    vb.net Code:
    1. If licenseExpiryDate < Date.Today.AddDays(30) Then
    2.     'The license expires in the next 30 days.
    3. End If
    If it' something else you want, you're going to have to explain more clearly.
    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

  4. #4

    Thread Starter
    Registered User
    Join Date
    Mar 2018
    Posts
    3

    Re: Change color of a lable based upon date comparison

    Thanks Jmcilhinney, That snippet is exactly what I was after. Shaggy, I have to apologize I have asked the question back to front, when the program starts it will check the license dates, among other things, and if a license is going to expire in the next 30 days it will add a message, similar to the task bar in outlook. I like your idea of changing the forecolor.
    Thanks for your help

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,914

    Re: [RESOLVED] Change color of a lable based upon date comparison

    I should point out that the comment in my code example wasn't completely accurate. It would be more correct to say this:
    vb.net Code:
    1. 'The license has expired or expires in the next 30 days.
    If you want to differentiate those that have already expired then you need another comparison, but I would hope that you could implement that for yourself.
    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

  6. #6

    Thread Starter
    Registered User
    Join Date
    Mar 2018
    Posts
    3

    Re: [RESOLVED] Change color of a lable based upon date comparison

    Quote Originally Posted by jmcilhinney View Post
    I should point out that the comment in my code example wasn't completely accurate. It would be more correct to say this:
    vb.net Code:
    1. 'The license has expired or expires in the next 30 days.
    If you want to differentiate those that have already expired then you need another comparison, but I would hope that you could implement that for yourself.
    Yes Thanks for that, Cheers Daz

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.