Results 1 to 8 of 8

Thread: Timer question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143
    Hi

    when I create a timer can i just paste some code into it and it will constantly refresh itself I.E evry 50 millisecond ?

    Example:
    Code:
    Private Sub tmrCheck_Timer()
    
    NumberOfUsers = frmUsers.txtOperator.Count - 1
    For i = 0 To NumberOfUsers
    
    If Text2.Text = frmUsers.txtOperator(i).Text & " : " Then
    
    If Text2.Text = frmUsers.txtOperator(i).Text & " : " & "?help" Or frmUsers.txtOperator(i).Text & " : " & Text2.Text = "?Help" Then
    Text1.Text = "This is the help menu"
    Send_Click
    
    Else
    
    End If
    End If
    
    Next i
    
    End Sub
    (I know the code abowe is somewhat unclean but thats not important right now)

    because I need the code to constantly search the text box for that string and using a loop function did just hang the computer

    im not used to use timers (hardly use them at all)

    some help would be appreciated
    Thanks.


    -Lumin

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Why dont you just chuck the code in there, run it and see for yourself????

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143
    Because I tried the example abowe and it didn't work, so I thought I might hadleft somthing out.

    anyway if i set the count to 0 in the timer controll will it update at all then ?


    -Lumin

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Ok, here are a few tips.


    1. If you set the timer to 0 it wont work at all
    2. When you first get into the timer function set it to 0
    3. Do your stuff in the middle
    4. Set the Interval to what you want before you leave.

    The reason for doing this is so that it wont even attempt to go off while you are actually running the code inside it. If the interval you set is too short then it cannot go off again while it is currently being run so it doesn't go off again.

    Setting it to 0 to begin with says "While I am doing this, I dont want it to work again"

    Setting it to the interval you require when you finish (ie the very last line) says "I want it to go off again in X milliseconds from NOW"

    Try that

  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    TO CONSTANTLY CHECK THE TEXT BOX YOU SHOULD USE THE TEXT_CHANGE EVENT FORM THE TEXTBOX
    ANY QUESTION
    [email protected]

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143
    I have already tried the text change event, and it didn't work for some reason.

    Right now it feels like this project never is going to work.

    BTW. thanks for the help Gen-X


    -Lumin

  7. #7
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Something just occured to me... and it may solve your problem.


    After the line Text1.Text = ....

    Add the following

    Code:
    Text1.Refresh
    What this does is forces the control to refresh its contents and in some cases forms dont get a chance to refresh with other events being triggered.

  8. #8
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305
    Another thing you want to be sure is that the Timer1.Enabled = True.

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