08 March 2014

How to make Text Animation using Visual Basic

ថ្ងៃនេះខ្ញុំសូមបង្ហាញអ្នកពីវិធីធ្វើអោយ Label សរសេរដោយខ្លួនឯងនៅពេលដែលអ្នកចុចលើប៊ូតុង Start Animate ឬក៏នៅពេលដែល Form Load.



1. ដំបូងអ្នកត្រូវបើកកម្មវិធី Visual Basic
2. Create New Project
3. គូស Label 1, Button 1 និង Timer1
4. ធ្វើតាមកូដខាងក្រោម

Public Class Form1
    Public str_ As String
    Public count_ As Integer

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Label1.Text.Length = str_.Length Then
            Timer1.Enabled = False
            Exit Sub
        End If
        Label1.Text = str_.Substring(0, count_)
        count_ = count_ + 1
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = ""
        count_ = 1
        str_ = "Hello! This show you about text animated."
        Timer1.Enabled = True
    End Sub
End Class






*** ចំណាំ : បើអ្នកចង់អោយវាមានចលនានៅពេល Form Load គ្រាន់តែផ្លាស់ប្ដូរកូដនៅ Button1 មកសរសេរក្នុង Event Form Load វិញជាការស្រេច។


SamnengIT © 2014-2015SamnengIT