CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Comparing field value to system clock

  1. #1
    Join Date
    Jan 2013

    Comparing field value to system clock

    Hello All,

    I'm very new to VB, and excited to learn it. I have a problems with my conditional logic that I have written which compares the field value DateTime from my table to the system time, and return a different background color. Here is my logic..

    if scheduledTime is 0-15mins late, then background color red
    if scheduledTime is 15mins-30mins late, then background color yellow
    if scheduledTime is 30mins-2hours late, then background color green.

    Here is my code so far...

    Dim systemTime As Date = Date.Now
    Dim fieldTime As Date = SCHD_DTM.CurrentValue
    Dim result As Double = (fieldTime - systemTime).TotalMintues
    if result <= 0.25 Then
    RowATTrs("style") = "background-color:red;"
    Else If result > 0.25 & result <= 0.5 Then
    RowATTrs("style") = "background-color:yelow;"
    Else If results > 0.5 & result <= 2 Then
    RowATTrs("style") = "background-color:Green;"
    End If
    Thanks for the help!

  2. #2
    Join Date
    Aug 2009
    NW USA

    Re: Comparing field value to system clock

    .25 is 15 seconds

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Comparing field value to system clock

    Yep those values in the if statements need to be 15 30 and 120 since you are dealing with total minutes not hours

    I would also say that the color code seems a bit odd. Red for a little late Yellow for quite a bit late and green for very late. ???? Seems like if anything it should be reversed.
    Last edited by DataMiser; January 15th, 2013 at 09:02 PM.
    Always use [code][/code] tags when posting code.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)