Results 1 to 6 of 6

Thread: Which use?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    29

    Which use?

    Hi,

    I search around VbForums trying to find the best way to make some Events running every X minutes (define by user, each minute up to 2 hours).

    I know the Timer object. I found GetTicketCount and SetTimer API. But I don't know which one is the best for my needs. I don't want something that eat up CPU.

    I want to know your opinion about it.

    Thanks a lot guys.

  2. #2
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196
    What is it you want to do exactly. You could manage to just run a basic timer and set the interval like so:

    VB Code:
    1. Private Sub Command1_Click()
    2.    timer1.interval = text1.text
    3.    timer1.enabled = True
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7.    'Your commands go here
    8. End Sub
    This will get the timers interval from a text box then enable the timer. Once enabled it will run the commands attached to itself...

    Note: Timers run in milliseconds (1 second = 1000 millisecond)
    I really dont understand what you're trying to do...sorry
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    29
    It's because I read that the Timer object was limited to 65 XXX (equal to ~1 minute) so if the user ask to make a check every 2 hours I didn't see how I can do it with this ojbect.

    I made a program who check every X minutes (or hour) the IP of a router (IP provide by the ISP). So I want to let the user choose himself the interval of the check.

  4. #4
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196

    This gets tricky...

    I see your dilemma. Im not good with API so I have 2 non-API solutions for you...but be aware API is probably better than these two:

    Solution 1: The variable way!
    VB Code:
    1. Dim time as integer
    2.    Dim min as integer
    3. Private Sub Command1_Click()
    4. 'get the time in min not seconds
    5.    min = text1.text
    6.    time = 0
    7. End Sub
    8. 'Timer interval should be 60000 (one min)
    9.    Private Sub Timer1_Timer()
    10. 'Add 1 to time every 1 min
    11.       time = time + 1
    12.    End Sub
    13. 'Check if the time is up
    14.    Private Sub Timer2_Timer()
    15.       If time = min then
    16. 'Put your commands here
    17.       End If
    18.    End Sub
    Solution 2: The math way!
    I can only explain this one. If you get the system time and put it in Var1 then get the system time + interval and put it in Var2 then make an If statement:
    VB Code:
    1. If var1 = var2 then
    2. 'Your commands here
    3. End If

    I didn't do this in VB so there may be syntax errors!
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    29
    Thanks Illiad, I will try this.

    Someone got something with API? I want to learn more about those method.

    Thanks

  6. #6
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196
    Try posting in the API forum. It may give more results...
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width