Solved

Time Alert

Posted on 2001-06-18
7
219 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
Technology Partners: 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 30 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 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…

738 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