Question Typer Writer Effect...

PRo-Beaniie

Well-known member
Joined
Mar 17, 2011
Messages
55
Location
Hertford, Hertfordshire, United Kingdom
Programming Experience
3-5
Hey Guys,

I am almost finished with my vb.net application however, want to put in a introduction the the game. the code i am looking for is code that can make the text on screen appear in sequence like a type writer...

this affect is seen in many military films, is there anyway to generate this affect on a mass scale because i will need to write about a paragraph of text ... :) :confused:

Many Thanks,
 
You can do this a plethora of ways -- With a timer, animated gif, and probably a few other ways.

Public Class Form1
    Public strToPrint As String = "This is the information I would like to have typed into my label to see what happens."
    Dim index As Integer = 0
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Interval = 100
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            Label1.Text += strToPrint(index)
            index += 1
        Catch ex As Exception
            Timer1.Stop()
        End Try
    End Sub
End Class
 
Call ToCharArray on a String to create, as you'd expect, a Char array. Declare an Integer variable to act as an index into that array. Add a Timer to your form and, in the Tick event:

1. Get the Char at the current index.
2. Append that Char to the displayed text, wherever that may be.
3. Increment the index.
4. If the index goes beyond the end of the array, stop the Timer.
 
Back
Top