Solved

Time Difference problem

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA: Select SQL query based on a config Sheet v2 11 44
Problem to With line 4 57
vbModal 12 51
Advice in Xamarin 21 78
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

776 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