Solved

Time Difference problem

Posted on 2002-04-24
3
199 Views
Last Modified: 2010-05-02
Heres what I need to do:
1. get "day" start time, "night" start time, from user
2. get time right now
3. determine by the above info if it is presently "day"   or "night"
4. done

Sounds easy huh?  well I've had  a pretty hard time with it.

I would like accept values like "7:00 PM", "11:32 AM" for the start times, will this work?, or will it need to be 24 hour format?


Dave

 
0
Comment
Question by:DaveMon
  • 2
3 Comments
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6965193
its better you accept in 24 Hrs Format and check the current time is less than the night time then say "Day" otherwise Say "Night"

Thats it.

Narayanan
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 6965200
The format is not really important:

Dim Morning As Double
Dim Night As Double
Dim Test As Double
Morning = CDbl(CDate(txtMorning.Text))
Night = CDbl(CDate(txtNight.Text))
Test = CDbl(CDate(txtTimeToTest.Text))
If Test < Morning Or Test > Night Then
  Msgbox "Nightime"
Else
  Msgbox "DayTime"
End If
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6965204
Here is the code

Private sub cmdShow()
Dim tm As String
tm = Format(Now, "HH:MM:SS")
If tm < nightStart.Text Then
    MsgBox "Day"
Else
    MsgBox "Night"
End If
End Sub

Cheers

Narayanan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DO Loop not working 4 72
Excel object stays open 19 71
Excel - Save a copy of work book 13 83
fso.FolderExists("\\server\HiddenFolder$") 4 52
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now