Is there a way to do this in VB? I would like to have an app up and running and at a certain time everyday perform a task?
Thanks for any help.
Printable View
Is there a way to do this in VB? I would like to have an app up and running and at a certain time everyday perform a task?
Thanks for any help.
well, this is how id do it.
VB Code:
if now = (time/date/whatever) then call jesus
is that what you wanted?
Quote:
Originally Posted by |2eM!x
In theory yes... just wondering if there was a type of clock/control that once it hit a certain time in the day that it might be able to call a function. With the code you posted I would have to have a nonstop loop checking if now is the right time and would rather not do that...
Thats the only way you are going to do it using VB. If you are using SQL Server or Oracle, you might be able to write a Stored Procedure to do whatever function you need done and have it kick off at a certain time.Quote:
Originally Posted by Besoup
If you are using Access, then I think you would have to develop some type of Server side Service that ran at the OS level.
Why does your app have to be up and running all day long just for this?Quote:
Originally Posted by Besoup
Windows has a schedule task feature for you to select a date/time for a .EXE to be run. The .EXE should really have no form - just a SUB MAIN area of code - and that executes and when done, exits.
Kind of like a service.
We have lots of these little .EXE jobs run from SQL Agent - and a couple from SCHEDULE TASKS...
Never thought of writing something for Scheduled tasks, probalby will be the best way to do it.... to answer your question of being up all day, the main app I am working on is going to be up all day just running processes of a regular timer.Quote:
Originally Posted by szlamany
or run a timer,you could run something every 60 seconds or something that way also
BTW I have never just made a .exe without form in VB. How would I declare a main sub in a VB Class?Quote:
Originally Posted by szlamany
tried :
VB Code:
Sub Main() 'put code in End Sub
code didn't run off the .exe... any ideas?
Menu - PROJECT>PROPERTIES>General Tab...Quote:
Originally Posted by Besoup
Startup Object -set to Sub Main - should do it.
Tried that and am now getting:
"Must have startup form or Sub Main()"
I have:
VB Code:
Sub Main() MsgBox "OMG" End Sub
Am I not putting the code in the right place? :sick:
I just started a brand new project.
Added a MODULE.
Put into that MODULE a SUB called MAIN
Set the STARTUP OBJECT to "SUB MAIN".Code:Sub main()
MsgBox "hello"
End Sub
Ran it and got the message box!
Got it thanks... I guess it would help not to have the main sub in the form code :PQuote:
Originally Posted by szlamany