Sunday, 18 December 2016

Animation - Blinking and Changing Color Effects of Text in vb.net

This tutorial will teach you how to create a program that has a blinking and changing color of the texts using vb.net.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add only one label named Label1 and one timer named Timer1.
3. Now, let's do the coding.
First, we will have to declare some variables that we will use.
                   Dim i As Integer = 0
                   Dim j As Integer
For our main code, we will prefer to code for the Tick Event of the timer. We will have the forecolor blue and red for our blinking effect and a moving text from right to left. Put any words also on the string
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim str As String = "vowbme.blogspot.com"
        Dim c(str.Length) As Char
        c = str.ToCharArray
        If j = 0 Then
            DspLabel1.ForeColor = Color.Blue
            If i < str.Length Then
                DspLabel1.Text = DspLabel1.Text & c(i)
                i = i + 1
            Else
                i = 0
                DspLabel1.Text = ""
            End If
            j = 1
        Else
            j = 0
            DspLabel1.ForeColor = Color.Red
        End If
    End Sub

Lastly, we will code for the Form_Load. We will just start the timer here.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

Output:

0 comments:

Post a Comment