ads_header

How To Create Fade In And Fade Out In Visual Studio


How To Create Fade In And Fade Out In Visual Studio



Preview



Hello guys, now I'm going to discuss about creating a fade in and fade out effect in a Form in Visual Studio 2010. Fade In is an effect on an image or animation that over time appears on a stage or screen, while Fade Out is the opposite, the animation made effect disappears little by little from the screen.

There are many types of effects, one of which is a favorite is Fade in Fade out. This tutorial is quite simple and easy to practice. By using the Fade In Fade Out effect, it will feel more meaningful to art in the programs we make and of course this will be added value.

Okay, we start the tutorial, as usual create a new project and prepare two forms. For Form1 just add a button to display Form2 with Fade In effect.


Similarly, Form2 adds one button to close Form2 with Fade Out effect.


Reopen Form1 and double-click Button1 and enter the following code to call Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
    Me.Visible = False
    Form2.ShowDialog()
End Sub





Then open Form2 and enter the following code in the Form Load event for the Fade In effect

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  
     Dim a As Integer
     For a = 10 To 100 Step +1
         Me.Opacity = a / 100
         Me.Refresh()
         Threading.Thread.Sleep(15)
     Next
End Sub


Reopen Form2 and then double-click Button1 and enter the following code for the Fade Out effect

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click   
     Dim a As Integer
     For a = 100 To 10 Step -1
         Me.Opacity = a / 100
         Me.Refresh()
         Threading.Thread.Sleep(15)
     Next
     Me.Close()
End Sub

NOTES :

The number 15 you can adjust how long the duration of Fade In and Fade Out effects
When done, the program is ready to run.

For more details, please watch the video below


No comments:

Powered by Blogger.