By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

Vb App - Schedule?

iam_clint
Expert 100+
P: 1,208
I am having a problem with an App i've tried a couple different routes..


I need to call a function in one of my vb apps at set times. Even while logged out of the "server" its going to be running on... So I have my app running as a service but even with my api timer the function never fires. Any help on this would be appreciated.

-- the function fires at the set time if i'm logged into the computer with the app open at set time --
Jan 28 '08 #1
Share this Question
Share on Google+
13 Replies


daniel aristidou
100+
P: 491
I need to call a function in one of my vb apps at set times. Even while logged out of the "server" its going to be running on... So I have my app running as a service but even with my api timer the function never fires. Any help on this would be appreciated.
-- the function fires at the set time if i'm logged into the computer with the app open at set time --
Hi could you post the code used to fire the function.
Daniel(~_~)
Jan 28 '08 #2

iam_clint
Expert 100+
P: 1,208
Expand|Select|Wrap|Line Numbers
  1. Public WithEvents mobjTmr As vbAPITimerTools.APITimer
  2. 'on initiate it does this
  3. Set mobjTmr = New vbAPITimerTools.APITimer
  4. mobjTmr.StartTimer 100
  5.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub mobjTmr_Refresh()
  2.     Dim curTime As Date
  3.     curTime = Time
  4.     strDate = Format(curTime, "HH:MM:SS AM/PM")
  5.     ccTime.Caption = strDate
  6.     If (strDate = "2:01:00 AM") Then
  7.         Call Form_Load
  8.         Call Command1_Click
  9.     End If
  10. End Sub
  11.  
Jan 28 '08 #3

daniel aristidou
100+
P: 491
Expand|Select|Wrap|Line Numbers
  1. Public WithEvents mobjTmr As vbAPITimerTools.APITimer
  2. 'on initiate it does this
  3. Set mobjTmr = New vbAPITimerTools.APITimer
  4. mobjTmr.StartTimer 100
  5.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub mobjTmr_Refresh()
  2. Dim curTime As Date
  3. curTime = Time
  4. strDate = Format(curTime, "HH:MM:SS AM/PM")
  5. ccTime.Caption = strDate
  6. If (strDate = "2:01:00 AM") Then
  7. Call Form_Load
  8. Call Command1_Click
  9. End If
  10. End Sub
  11.  
Hi ..
Try changing this line...
Expand|Select|Wrap|Line Numbers
  1.  strDate = Format(curTime, "HH:MM:SS AM/PM") 
  2. ccTime.Caption = strDate
  3. If (strDate = "2:01:00 AM") Then
  4. Call Form_Load
  5. 'To 
  6. strDate = Format(curTime, "HH:MM AM/PM")
  7. ccTime.Caption = strDate
  8. If (strDate = "2:01 AM") Then
  9. Call Form_Load
  10.  
Question just to be sure the 100 in this line is the interval?
mobjTmr.StartTimer 100
Jan 28 '08 #4

Expert 5K+
P: 8,434
Expand|Select|Wrap|Line Numbers
  1.  strDate = Format(curTime, "HH:MM:SS AM/PM") 
  2. ...
  3. strDate = Format(curTime, "HH:MM AM/PM")
Why would changing the time format make any difference? In fact, wouldn't this potentially cause the process to happen multiple times when it's only wanted once? Or does the "100" mean ten seconds, or something?
Jan 29 '08 #5

iam_clint
Expert 100+
P: 1,208
100 is 100 milliseconds and changing the time format shouldn't change anything since when I am logged in the app fires on time every time...
100 milliseconds should hit within that 1 second period about 9 times at least. but since the app would be busy it wouldn't hit it more than once. the app takes well over 30 minutes to finish what its doing.

when i'm not logged into the system (not logged in... not shut down just not logged in) it doesn't fire.
Jan 29 '08 #6

daniel aristidou
100+
P: 491
100 is 100 milliseconds and changing the time format shouldn't change anything since when I am logged in the app fires on time every time...
100 milliseconds should hit within that 1 second period about 9 times at least. but since the app would be busy it wouldn't hit it more than once. the app takes well over 30 minutes to finish what its doing.

when i'm not logged into the system (not logged in... not shut down just not logged in) it doesn't fire.
To make things Clear........
The if Statement never returns True?
Or
When The If statement = True ;you get no results?
Also
Does the loggin have any relation to the timer you are using? To check this you might want to try disableing the login function....
I think the problem might be to do with the login...
Can explain the login logic you are using.
Jan 29 '08 #7

iam_clint
Expert 100+
P: 1,208
To make things Clear........
The if Statement never returns True?
Or
When The If statement = True ;you get no results?
Also
Does the loggin have any relation to the timer you are using? To check this you might want to try disableing the login function....
I think the problem might be to do with the login...
Can explain the login logic you are using.
Not a login for the app .. Windows login

No relation to the timer.


the events fire when the app is running and logged into windows

when the app is running and your not logged into windows no events fire.
Jan 29 '08 #8

Expert 5K+
P: 8,434
I don't know whether it matters, but what version of Windows?

Also, I'm thinking this question might be better handled in the Windows forum, as it's probably not a language-specific issue. If I'm reading it correctly, you just need to know how to get an application loaded as a service to process timer events when nobody is logged in.
Jan 29 '08 #9

iam_clint
Expert 100+
P: 1,208
its windows 2003 server
Jan 30 '08 #10

P: 58
How about using the Task Scheduler?
Jan 30 '08 #11

kadghar
Expert 100+
P: 1,295
Why would changing the time format make any difference? In fact, wouldn't this potentially cause the process to happen multiple times when it's only wanted once? Or does the "100" mean ten seconds, or something?

I dont think its such a weird idea, i think that while working with dates, its better to use an interval in the IF rather than an exact time.
i.e.

you may be so lucky that if you say
Expand|Select|Wrap|Line Numbers
  1. If MyTime = "2:30 AM" then
  2.   'Do something
  3. End if
Will work if the timer tics in that very moment

But i'd say that something like:
Expand|Select|Wrap|Line Numbers
  1. if mytime >= "2:30 AM" and mytime < "2:31 AM" then
  2.     'Do something
  3. End if
with a larger interval will do

But since you dont know the speed of the users computer, to make sure the event will only happen once, but it'll certainly happen, write (inside the timer) something like

Expand|Select|Wrap|Line Numbers
  1. Dim Boo1 as boolean
  2. If mytime <= "2.30 AM" then boo1=true
  3. if mytime >= "2.30 AM" and Boo1 = true then
  4.     'Do something
  5.     boo1=false
  6. end if
or any other variant of "using a boolean to only do it once" will help.
Jan 30 '08 #12

kadghar
Expert 100+
P: 1,295
its windows 2003 server
I dont know where does it gets the time from, if its from the logged in client, why dont you try making your "own clock" in the app that refreshes each time somebody is logged in, so when nobody is, instead of checking the system's time, it'll check the one you created.

This might give you some headaches, cause if nobody logs in for a while, it wont be sharp on time. But it's an alternative in case you dont find how to call the time when nobody is logged in.
Jan 30 '08 #13

iam_clint
Expert 100+
P: 1,208
(this is my server its running on i know its settings.) the app won't fire while i'm "logged off" of windows.. but the app will fire while i'm "logged in" windows.

You think that the system time changes or doesn't update while a user isn't logged in?
Jan 31 '08 #14

Post your reply

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