Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setTimer and KillTimer to make Typewriter effect?

Status
Not open for further replies.

Sidro

MIS
Sep 28, 2002
197
US
HI,
how can I use these two functions to make a typewrtier effect? Anyone ever tried it?
 
Could you be more specific on what are you trying do to?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
hi,
what im trying to do is scan each char in a string,wait a second or two then scan another char,wait a second , scan another char,ect...until it finishes the whole string.
To delay I have used the Sleep function, the GetTickcount and now the SetTimer function. The Sleep function and the GetTickCount function wont allow me to break out once its been fired. The SetTimer functin works great but it doesnt
execute the lines of code sequencially. I know I can use the vb timer function but its too confusing for me.Im trying to make it into a function that looks like this
" Delay(100)", the argument is the number of seconds to delay but I cant do that with vb timer. CAn Anyone make it so that its just one functino that accepts an argument, like Delay(30) with the vb timer?Thankx in advance.

Example,

dim line as string
dim count as integer
line="Hello World!"

for count=1 to len(line) step 1
"Here I would like it to delay a bit before print another char , trying to make a function that looks like this
Delay(30), but with no luck"
text1.seltext=mid(line,count,1)
next
 
To use a timer just add a timer control to your form. When you want to start, just set Timer1.Interval to 1000 for 1 second repeats and set Timer.enabled to True. Stick this code in your Timer event:

Private Sub Timer1_Timer()
Static temp
temp = temp + 1
if temp > len(mystring) then
timer1.enabled = false
end if
text1.text = text1.text & mid(myString,temp,1)
End Sub

This will print a Public variable myString into Text1 character by character


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
hi,
so any code that I want to be executed after the timer fires has to be inside the timer function?
 
Yes. The code in the Timer event is run everytime that the timer fires. The timer starts running when Interval is set to anything between 1 and 65535 and Enabled is set to True. It will then fire again every (Interval) millisecs until it's disabled or until it's Interval is set to 0

The thing that changes this is if VB is doing something else using all the processor time (like running in a loop process without DoEvents in the loop)


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top