Solved

Time Difference problem

Posted on 2002-04-24
3
202 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

860 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