Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Time Alert

Posted on 2001-06-18
7
Medium Priority
?
223 Views
Last Modified: 2010-05-02
Hi All,
I am using vb6.  I want Alert after 1 hour from morning
8 till evening 8.  How i can detect time format.  If the
time is in AM or PM or Normal or how we can detect time
format from regional setting.  I need asap.
bye
0
Comment
Question by:Noor
[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
  • 4
  • 2
7 Comments
 
LVL 1

Expert Comment

by:CJHarrap
ID: 6201382
Use a Timer Control to run an Event every 1 sec or so.... or whatever time you want. Add the Timer control to a form.

add this to top of form module.
dim mytime as string 'make mytime public

On the form load or under a command button use
mytime = format(inputbox("Enter Time to fire off alert"),"HH:MM:SS")

In the Timer event use something like
dim curtime as string
curtime = format(now(),"HH:MM:SS")

if mytime = currtime then
Msgbox "Alert"

End if


You get the idea....

Cheers,

CJ.

0
 
LVL 18

Expert Comment

by:deighton
ID: 6201408
Option Explicit

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Main()

    Dim datTime As Date
    Dim lDelay As Long
   
   
    While True
   
    datTime = Now - Int(Now)
   
    If datTime >= 20 / 24 Then
   
        lDelay = DateDiff("s", datTime, TimeSerial(8, 0, 0) + 1)
       
    ElseIf datTime <= 8 / 24 Then
   
        lDelay = DateDiff("s", datTime, TimeSerial(8, 0, 0))
   
    Else
   
        lDelay = DateDiff("s", datTime, TimeSerial(Hour(datTime) + 1, 0, 0))
   
    End If
   
    lDelay = lDelay * 100
   
    Sleep lDelay

    MsgBox Time

    Wend

End Sub
0
 
LVL 18

Expert Comment

by:deighton
ID: 6201417
ignore the above, should have been

Option Explicit

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub main()

    Dim datTime As Date
    Dim lDelay As Long
   
   
    While True
   
    datTime = Now - Int(Now)
   
    If datTime >= 20 / 24 Then
   
        lDelay = DateDiff("s", datTime, TimeSerial(8, 0, 0) + 1)
       
    ElseIf datTime <= 8 / 24 Then
   
        lDelay = DateDiff("s", datTime, TimeSerial(8, 0, 0))
   
    Else
   
        lDelay = DateDiff("s", datTime, TimeSerial(Hour(datTime) + 1, 0, 0))
   
    End If
   
    lDelay = lDelay * 1000
   
    Sleep lDelay

    MsgBox Time

    Wend

End Sub
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Noor
ID: 6202425
It's great but if we run the exe and when we want to change
the Time from the Date/Time Properties, then the Date/Time Properties will hang. Any idea about this.  I am running Windows 98 OS
0
 
LVL 18

Accepted Solution

by:
deighton earned 90 total points
ID: 6206027
'try this one

Option Explicit



Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Main()

   Dim datLast As Date
   Dim datNow As Date
   
   datLast = Now
   datNow = Now
   
   If App.PrevInstance Then End
   
   Do
   
        If (Hour(datNow) - Hour(datLast)) = 1 And Hour(datNow) >= 8 And Hour(datNow) <= 20 Then
            MsgBox CDate(Now - Int(Now))
        End If
   
        datLast = datNow
        Sleep 500  
        DoEvents
        datNow = Now
   
    Loop Until False
       
               
End Sub
0
 

Author Comment

by:Noor
ID: 6213263
No difference, Date-Time properties hanging
0
 
LVL 18

Expert Comment

by:deighton
ID: 6213418
Option Explicit



Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Main()

  Dim datLast As Date
  Dim datNow As Date
 
  datLast = Now
  datNow = Now
 
  If App.PrevInstance Then End
 
  Do
 
       If (Hour(datNow) - Hour(datLast)) = 1 And Hour(datNow) >= 8 And Hour(datNow) <= 20 Then
           MsgBox CDate(Now - Int(Now))
       End If
   
       datLast = datNow

       DoEvents
       datNow = Now
   
   Loop Until False
       
               
End Sub
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

715 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