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?
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
Re: Change text multiple times..
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
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
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.