-
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
-
Why dont you just chuck the code in there, run it and see for yourself????
-
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
-
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
-
TO CONSTANTLY CHECK THE TEXT BOX YOU SHOULD USE THE TEXT_CHANGE EVENT FORM THE TEXTBOX
ANY QUESTION
[email protected]
-
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
-
Something just occured to me... and it may solve your problem.
After the line Text1.Text = ....
Add the following
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.
-
Another thing you want to be sure is that the Timer1.Enabled = True. :)