|
-
Aug 2nd, 2007, 10:41 PM
#1
Thread Starter
New Member
Change text multiple times..
I did a simple search, really couldn't think of what to search for so I figured I'd post.
What I'm trying to do is change the text in a textbox to "h" then "he" forming up to hello. What I don't want to do is use multiple timers(hate doing this). So basically I'm asking, is there a way to do this with a single Timer some how? Or any other way besides using more than one timer?
Last edited by Souljahz0r; Aug 3rd, 2007 at 12:16 AM.
-
Aug 2nd, 2007, 10:46 PM
#2
Re: Change text multiple times..
Code:
Private mstrDisplay As String
Private Sub Form_Load()
mstrDisplay = "Hello, world!"
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static slngLen As Long
slngLen = slngLen + 1
If slngLen > Len(mstrDisplay) Then
Timer1.Enabled = False
slngLen = 0
Else
Text1.Text = Left(mstrDisplay, slngLen)
End If
End Sub
-
Aug 2nd, 2007, 11:27 PM
#3
Thread Starter
New Member
Re: Change text multiple times..
Sweet, thanks
-
Aug 3rd, 2007, 12:17 AM
#4
Thread Starter
New Member
Re: Change text multiple times..
I tried messing around with that code but couldn't quite get it. How can I make it go back down like "Hello" goes to "Hell" "Hel" etc etc
-
Aug 3rd, 2007, 12:47 AM
#5
Addicted Member
Re: Change text multiple times..
Code:
Private mstrDisplay As String
Private Direction As String
Private slngLen As Integer
Private Sub Form_Load()
mstrDisplay = "Hello, world!"
Timer1.Interval = 100
Timer1.Enabled = True
Direction = "FW"
slngLen = 1
End Sub
Private Sub Timer1_Timer()
If Direction = "FW" Then
Text1.Text = Mid(mstrDisplay, 1, slngLen)
slngLen = slngLen + 1
If slngLen >= Len(mstrDisplay) Then Direction = "BW"
Else
Text1.Text = Mid(mstrDisplay, 1, slngLen)
slngLen = slngLen - 1
If slngLen <= 0 Then Direction = "FW"
End If
End Sub
-
Aug 3rd, 2007, 07:29 AM
#6
Re: Change text multiple times..
I'd keep the logic in the Timer() sub:
Code:
Private mstrDisplay As String
Private Sub Form_Load()
mstrDisplay = "Hello, world!"
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static slngLen As Long
Static slngIncrement As Long
Select Case slngLen
Case 0: slngIncrement = 1
Case Len(mstrDisplay): slngIncrement = -1
End Select
slngLen = slngLen + slngIncrement
Text1.Text = Left(mstrDisplay, slngLen)
End Sub
This will keep it bouncing back and forth between growing and shrinking.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|