?
Solved

Time Difference problem

Posted on 2002-04-24
3
Medium Priority
?
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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