|
-
Sep 9th, 2008, 08:34 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Between Two Times...
Hi guys..
I'm looking to have my program have a night, and day mode.. It pulls in the almanac every time it loads, and I'd like to have it so that when the "Sunrise"'s the program will be in day mode, and when the "Sunset"'s it will go in to night mode..
Is there a way I can say something like:
If time now is between sunrise.Text and Sunset.Text then mode = day
Else
mode = night
How do I actually write this?
-
Sep 9th, 2008, 09:54 PM
#2
Re: Between Two Times...
Code:
If Time >= TimeValue(Sunrise.Text) And Time <= TimeValue(Sunset.Text) Then
mode = day
Else
mode = night
End If
Make sure Sunrise.Text and Sunset.Text have valid time format values.
-
Sep 9th, 2008, 09:55 PM
#3
Thread Starter
Hyperactive Member
-
Sep 9th, 2008, 09:57 PM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED] Between Two Times...
I'm getting a "Type Mismatch"
Line:
Code:
If Time >= TimeValue(sunup.Caption) And Time <= TimeValue(sundown.Caption) Then
-
Sep 9th, 2008, 09:59 PM
#5
Thread Starter
Hyperactive Member
Re: [RESOLVED] Between Two Times...
I think it might involve that sunup.Caption simply reads "6:45"... Can I get my time from a label instead of the generic time?
-
Sep 9th, 2008, 10:10 PM
#6
Re: [RESOLVED] Between Two Times...
Code:
?Timevalue("6:45")
6:45:00 AM
?Timevalue("17:25")
5:25:00 PM
An alternative way:
Code:
Select Case TimeValue(Label1.Caption)
Case Is < TimeValue(sunup.Caption), Is > TimeValue(sundown.Caption)
mode = night
Case Else
mode = day
End Select
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
|