473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Timer Check for Days to Offline

Hi All,
I am using VB6. Iam new to VB6
I am new here looking for a solution to test for starttime and endtime of a time/day window. The users will input days of the week i.e. mon-Sun and the Starttime and Endtime for each day selected. Example a user can select Fri - Sun checkboxes and in each day choose a starttime of 07:00 and endtime 23:00 so the form will look like (no enetered values for Mon - Thurs) - System Offline settings forms

Checkbox Starttime textbox EndTime textbox
-------------------------------------------------------------------------
X Friday 07:00 23:59
X Saturday 00:00 23:59
X Sunday 00:00 19:59
Monday
Tue

Hence I want a counter to start counting down to when the system is about to go offline. Say on Friday at 06:00 the display counter will say " Time to OFFLINE 01:00:00 etc.

Hence my problem is on Monday how can i test for friday and have the counter start counting.

How will i design a do Loop to test for this condition ie. Do while xtime is not friday <starttime>

loop

I have done most the form and using GetSetting and SaveSetting for the values

The only problem it the timer loop to test for what user has selected and do the counter

Please help

Many thanks

Benitez
Oct 30 '07 #1
3 1199
nev
251 100+
I am new here looking for a solution to test for starttime and endtime of a time/day window ...
The timer should be enabled at all times. In the timer tick event place code something like...

Expand|Select|Wrap|Line Numbers
  1. select case currentday
  2.    case friday
  3.       if currenttime = fridaystarttime - 1 hour then
  4.          lblcountdown.text = fridaystarttime - currenttime & "till shutdown..."
  5.       end if
  6.    case saturday
  7.    case sunday
  8.    case and-so-on
  9. end select
I don't understand what you mean by this...
"Hence my problem is on Monday how can I test for Friday and have the counter start counting."

Note: I did not bother the performance of this code. You do the necessary changes to make it process faster.
Oct 31 '07 #2
Hi Nev,
Thanks for the quick response. I will try this logic and will let you know.
What I mean is if the day is Monday how will i count to Friday's starttime if Friday 19:00 is selected as the shutdown day, because there are upto 3 days inbetween same with tues as there are 2 days to count and so on.

Kind REgards.

Benitez
Oct 31 '07 #3
Killer42
8,435 Expert 8TB
The first thing I'd suggest is to write a couple of functions to (a) identify the next "down time", and (b) calculate the time remaining until then. Once you create them, even if you haven't filled in what they do yet, you can go ahead with building the logic that uses them. For instance...

Expand|Select|Wrap|Line Numbers
  1. Public Function NextDownTime() As Date
  2.   ' This function will determine the next time that the
  3.   ' system is scheduled to go down.
  4. End Function
  5.  
  6. Public Sub GetTimeRemaining(ByVal Until As Date, NumDays As Long, NumHours As Long, NumMins As Long, NumSeconds As Long)
  7.  
  8. End Sub
Then, in a timer for example, you can code something like...
Expand|Select|Wrap|Line Numbers
  1. Dim DD As Long, HH As Long, II As Long, SS As Long
  2.   GetTimeRemaining NextDownTime(), DD, HH, II, SS
  3.   txtRemaining.Text = "Time to OFFLINE... " & _
  4.       DD & " days, " & HH & " hours, " & II & " minutes, " & _
  5.       SS & " seconds."
  6.  

As for the guts of the NextDownTime() function... hm... how about you start at Weekday(Now()) and loop through the day numbers until you hit one which has downtime. Unless it's the same day and earlier than Now() it must be the next one to occur.
Nov 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bonnett | last post by:
I have been creating a generic countdown timer (source code below), counting the seconds, minutes, hours and days till an event, but I have having trouble with it finding out how many hours are...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
1
by: Can Balioglu | last post by:
Hi, I don't know if it's already known but I found a bug in System.Timers.Timer class. The 'Interval' property accepts a double which specifies the interval between two 'Elapsed' events. The...
7
by: LBT | last post by:
I have a window service written using VB.NET. This window service will scan folders for file and grab the file content to be inserted to SQL Server on file detection. There are altogether 18...
9
by: archana | last post by:
Hi all, I want to know about interval of timer. I am using timer in windows service.I head somewhere that when i set interval property of timer while setting interval, restart time of Pc is...
4
by: rockkyy | last post by:
hi, i am storing a random token and userid,clientdata etc on a STL map container with the unique token as the KEY and the structure containg userid,clientdata etc as the VALUE. Now i want to...
10
by: igor | last post by:
I have recently discovered that the system.Timers.Timer from.Net Framework v1.1 is not reliable when used on Windows 2003 server. When incorporated into a Windows Service, the timer_elapsed event...
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
3
missshaikh
by: missshaikh | last post by:
Hi all, i need the count down timer when button click the timer start and count down work on ASP.net :( i have one timer which is on JavaScript that run page onload . but i need the Button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.