-
January 15th, 2013, 11:40 AM
#1
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...
Code:
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!
-
January 15th, 2013, 12:29 PM
#2
Re: Comparing field value to system clock
-
January 15th, 2013, 09:00 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|