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.'
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.'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.