How To Make A Cool Text Animation In VB.NET

anim

hello , animation in vb.net is really a cool thing and for this you are not going to use any type of labels or textboxes just we are coding but we need timer and a button the timer for you know for timing and the button to show the animation up so now lets begin making this don't worry this wont take much time or don't need to work hard because its already coded in the easiest way to understand and also to create. now create a new project in your visual basic 2008/2010 i tested this in visual basic 2010 and i don't have visual basic 2008 to test to i hope it work in visual basic 2008 . when the form finished loading now change the usual things in properties now from the toolbox add a timer(timer1) and a button(button1) now double click your form and add this codes


Public Class Form1

    'Author : Mohamed Shimran
    'Blog : http://www.ultimateprogrammingtutorials.blogspot.com

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        animateText("Hello /////.....//////", Button1.Location.Y - 20, Button1.Location.Y - 50, Button1.Location.X)
    End Sub
    Dim label As New Label
    Dim maxHeight As Integer
    Dim colour As Integer = 255
    Public Sub animateText(ByVal text As String, ByVal lowerBounds As Integer, ByVal upperBounds As Integer, ByVal xPos As Integer)
        maxHeight = upperBounds
        label.Text = text
        label.TextAlign = ContentAlignment.MiddleCenter
        label.Location = New Point(xPos, lowerBounds)
        label.Font = New Font(Font.Bold, 20) 'Feel free to customize the font size
        label.AutoSize = True
        Me.Controls.Add(label)
        Timer1.Enabled = True
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        label.Location = New Point(label.Location.X, label.Location.Y - 1)
        label.ForeColor = Color.FromArgb(colour, colour, colour)
        colour -= 7
        If colour <= 10 Then
            colour = 10
        End If
        If label.Location.Y = maxHeight Then
            Timer1.Enabled = False
            Me.Controls.Remove(label)
            colour = 255
        End If
    End Sub
End Class


now you see something like "hello ..." that's the text you can edit it and after that debug the program and enjoy

1 comments:

Post a Comment

Note: Only a member of this blog may post a comment.