4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by AndreRet
0

If you are trying to make the title of a form appear as though someone has typed it in, then the easiest way would be to use a timer that will update the caption with one letter on each run.

I'd say keep a module based integer variable which will hold the marker in the title. Maybe (for ease), have a module based string variable too which will hold the expected caption.

Then the timer should have code in it which would find the "MID" value of the caption string based on the position by the marker. Then increment the marker by one so it's ready for the next run.

Something along the lines of this.

Private m_iMarker As Integer
Private m_sCaption As String

Private Sub Command1_Click()
    Me.Caption = vbNullString
    m_sCaption = "Caption typing effect by jonifen"
    m_iMarker = 1
    tmrCaption.Interval = 400
    tmrCaption.Enabled = True
End Sub

Private Sub tmrCaption_Timer()
    If Len(Me.Caption) = 0 Then
        Me.Caption = Left$(m_sCaption, 1)
    Else
        Me.Caption = Me.Caption & Mid$(m_sCaption, m_iMarker, 1)
    End If
    
    m_iMarker = m_iMarker + 1
End Sub
0

If you want to add the caption as you type, use it in a text box change event. -

Private Sub Text1_Change()

Me.Caption = Text1.Text
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.