Hi,

i m trying to make a program (VB6) in which i need to do some tasks as soon as the date changes (like creating new database etc.), but dont know how to keep track of date change...searching on this gave me following -

1. Using a timer with 1 sec duration to keep track of date-change - but i suppose its a waste of memory resource
2. using windows task manager to fire a event every midnight - but i dont have a idea how to do this

Please suggest a way out..is there a event trigger for date change?? if not please help me to get clarity on above two solutions or any other method that u might think is a better solution..

Thanks in advance.

Recommended Answers

All 8 Replies

what is the database that you are using ?

Well for somthing that happens only once a day and only after midnight, you could increase the interval to its max, 65535, which is just over a minute...

Good Luck

Hi pankaj.garg,
you can use "AT" DOS command to schedule a single application to run on a specified day, once a week, or every day, and call you program to make what you want.

Some like this

> AT time NAME.EXE

For example, if your application is named MYAPP.EXE, and you want to execute them at 2 PM today, you should use

AT 14:00 MYAPP.EXE


Also, you can schedule it to run 1 AM, every day, using also like this

AT 1:00 /EVERY:M,T,W,Th,F,S,Su
or
AT 1:00 /INTERACTIVE /EVERY:M,T,W,Th,F,S,Su


Note: the switch "/INTERACTIVE" should be used if you want the user interact with your application; if not, use only "EVERY" switch, specifying the days of week you want to run you app.

NO TIMER or INFINITE LOOPS are needed in you application, and no need to remain open before do the tasks.


I hope this help you.
And I sugest you visit this link http://support.microsoft.com/?scid=kb;en-us;313565&x=13&y=17 it contains more detailed explains for use this command.


Best regards!
Sidnei

what is the database that you are using ?

i m using MS Access...and using DAO to access database..

Well for somthing that happens only once a day and only after midnight, you could increase the interval to its max, 65535, which is just over a minute...

Good Luck

Thanks...but i would like to refrain from using timer mainly cuz of reason - if i increase the time interval, i'll mixup data of two different dates..

thanks sidnei for the information...

let me check it and see how can i use it...though i'll be searching on net on how to give DOS commands using VB6..but if u have a ready reckoner plz let me know...

Thanks

Hi pankaj.garg,
you can use "AT" DOS command to schedule a single application to run on a specified day, once a week, or every day, and call you program to make what you want.

Some like this

> AT time NAME.EXE

For example, if your application is named MYAPP.EXE, and you want to execute them at 2 PM today, you should use

AT 14:00 MYAPP.EXE


Also, you can schedule it to run 1 AM, every day, using also like this

AT 1:00 /EVERY:M,T,W,Th,F,S,Su
or
AT 1:00 /INTERACTIVE /EVERY:M,T,W,Th,F,S,Su


Note: the switch "/INTERACTIVE" should be used if you want the user interact with your application; if not, use only "EVERY" switch, specifying the days of week you want to run you app.

NO TIMER or INFINITE LOOPS are needed in you application, and no need to remain open before do the tasks.


I hope this help you.
And I sugest you visit this link http://support.microsoft.com/?scid=kb;en-us;313565&x=13&y=17 it contains more detailed explains for use this command.


Best regards!
Sidnei

I'm pleased to help you...

I've been tested this on a Windows XP SP3 platform, and it works fine!
Simply go to the Start menu, Run, then type "COMMAND" and, in the text console mode that will be appear, type the command like I did before. The computer can be restarted or even shut down then power on again, and this scheduler don't get lose.


BUT, if you need to call this command directly from VB6 interface, you can use the SHELL method. This method calls the COMMAND interpreter and execute the command you pass by...

Take a look at this example...

Shell "AT 15:41 /INTERACTIVE ""NOTEPAD.EXE""", vbHide

The double quotes ("") is needed cause the VB interpretes one quote as the end of string; if you pass double quotes, then VB ignore and put ONLY ONE quote in the string.
The SHELL calls the XP console, and then execute the schedule for open Notepad app at a certain time. The "vbHide" parameters tells to VB6 how the console window will be open (vbHide - the user don't see the command window; you can test others parameters to find that fits your needs best).

If you want, you can schedule applications in remote machines, too.
After the AT command, put the IP address of the remote machine; others parameters will be the same. Like AT \\100.200.10.20 15:50 /INTERACTIVE "CALC.EXE" .


I hope you understand this explanation, my english is very poor...


Regards!
Sidnei

thanks sidnei for the information...

let me check it and see how can i use it...though i'll be searching on net on how to give DOS commands using VB6..but if u have a ready reckoner plz let me know...

Thanks

great !!!
thanks sidnei...solved my problem...
your explanation was fine...and so is your english

Thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.