Timer - is it possible in vb 6.0 to make a while statement which executes ever

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > VB Programming

Timer - is it possible in vb 6.0 to make a while statement which executes ever

it01y2
Is it possible in vb 6.0 to make a while statement which executes every 10 minutes?

Any ideas?

Reply

Galahad
QUOTE(it01y2 @ Jul 8 2008, 06:49 PM) *
Is it possible in vb 6.0 to make a while statement which executes every 10 minutes?

Any ideas?


Well, it's possible, but very ineffective... Insteda, you shoud look at API Guide... They have a complete list of API functions, and there are two that can be used for this what you need... They are advanced timer controls, and allow you to set a callback function, that will be called on interval you specify, and plus, it runs as a separate thread... I think they ahve something to do with quartz.dll... I'll try to find my old projects, and write you an example...

Edit:
I found a few good functions that you may find usefull:
CODE
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Currency
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Currency

Private Sub WaitMs(ByVal MS As Long) 'wait a given number of milliseconds
Dim t21 As Currency, f21 As Currency, e21 As Currency
QueryPerformanceFrequency f21  'get number of counts/second
t21 = f21 * MS / 1000# 'multiply f by number of seconds to get number of counts to wait
QueryPerformanceCounter e21  'get current count number
e21 = e21 + t21  'add number of counts to wait to current count
Do
  QueryPerformanceCounter t21
  If t21 > e21 Then Exit Do  'wait for current count to exceed e
  DoEvents
Loop
End Sub


I'm still looking for that separate thread function

Edit 2:
I couldn;t find what I was looking for, but try looking at this example HERE... I think it has everything you need, and it's sort of multi thread for VB6... I think that's the best choice for you...

 

 

 


Reply

moodsey211
why not use a timer instead. You could put your codes on the on timer event. VB provides a timer to do it. i thinks that would perfectly fit for the job. biggrin.gif

Reply

Galahad
QUOTE(moodsey211 @ Jul 14 2008, 03:09 AM) *
why not use a timer instead. You could put your codes on the on timer event. VB provides a timer to do it. i thinks that would perfectly fit for the job. biggrin.gif


He could, but Timer object isn't very precise... And if something occupies his program, Timer would miss his turn... So it wouldn't be 10 minutes, it would become 12 minutes... Multi-threading is the best way to go about, have an external process worry about minutes, and when the time comes, execute the code he needs... If on the other hand, those 10 mintes don't have to be 10 minutes, Timer object would be satisfactory...

Reply

moodsey211
QUOTE(Galahad @ Jul 19 2008, 12:08 PM) *
He could, but Timer object isn't very precise... And if something occupies his program, Timer would miss his turn... So it wouldn't be 10 minutes, it would become 12 minutes... Multi-threading is the best way to go about, have an external process worry about minutes, and when the time comes, execute the code he needs... If on the other hand, those 10 mintes don't have to be 10 minutes, Timer object would be satisfactory...


really??? but VB timer creates a different thread for its own execution. I've used it before for timer agents used in cafes and other apps that uses timers. I don't see any problem with it.

Reply

Galahad
QUOTE(moodsey211 @ Jul 21 2008, 08:48 AM) *
really??? but VB timer creates a different thread for its own execution. I've used it before for timer agents used in cafes and other apps that uses timers. I don't see any problem with it.

Nah, generic VB6 Timer doesn't create it's own thread, and it isn't quite precise... Yes, it's satisfactory if you don't need exact time intervals in a millisecond, but when precision is of the essence, it fails misserably... I wrote a programm that needed precise time intervals to poll certain hardware, and Timer failed to do the job, I had to write a separate thread timer using API, to achieve 20ms precision...

Reply

moodsey211
QUOTE(Galahad @ Jul 24 2008, 05:44 AM) *
Nah, generic VB6 Timer doesn't create it's own thread, and it isn't quite precise... Yes, it's satisfactory if you don't need exact time intervals in a millisecond, but when precision is of the essence, it fails misserably... I wrote a programm that needed precise time intervals to poll certain hardware, and Timer failed to do the job, I had to write a separate thread timer using API, to achieve 20ms precision...


ahhh. I've never have had wrote a program that really needs a precise time. may I ask if you turn on and off your timer? I mean during each execution of the timer you turn it off and after its execution you turn it on...

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. how to get timers of a thread in vb6 - 2.90 hr back. (1)
  2. vb6 do while on timers - 3.19 hr back. (1)
  3. vb6 timer code - 26.40 hr back. (2)
  4. make a timer in vb 2008 - 64.20 hr back. (2)
  5. how to use queryperformancecounter() to get very accurate timed events - 68.10 hr back. (1)
  6. timers vb 6.0 thread - 76.85 hr back. (1)
  7. timer in vb 6.0 - 81.09 hr back. (1)
  8. millisecond timer in vb6 - 90.44 hr back. (1)
  9. 10 minute timers - 92.71 hr back. (1)
  10. craigs list com - 100.79 hr back. (1)
  11. vb millisecond - 6.98 hr back. (2)
  12. how to get milliseconds for current time in vb 6.0 - 125.68 hr back. (1)
  13. vb6 timer.interval - 141.49 hr back. (1)
  14. how to work timer in vb 6.0 - 146.41 hr back. (1)
Similar Topics

Keywords : timer, vb, 6, 0, make, statement, executes

  1. Timer Control Key Press Every Minute Vb2005
    (0)
  2. Using A Timer In A Array...
    (2)
    I'm usually very well a creating a problems and then finding a solution. However this time
    I'm stumped. I'm attempting to create timers.. I know this is possible by doing...
    visual basic code:--------------------------------------------------------------------------------
    Option Explict Dim WithEvents tmrTimer1 As VB.Timer Private Sub Form1_OnLoad() Set tmrTimer1 =
    Me.Controls.Add("VB.Timer", "Timer1") End Sub
    -------------------------------------------------------------------------------- Now, what I need
    is to be able to create those timers, but creat....

    1. Looking for timer, vb, 6, 0, make, statement, executes

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for timer, vb, 6, 0, make, statement, executes

*MORE FROM TRAP17.COM*
advertisement



Timer - is it possible in vb 6.0 to make a while statement which executes ever



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE