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
Solved

Time Alert

Posted on 2001-06-18
7
216 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

837 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