How to make Forms Fade In / Fade Out

JizzaBeez Jan 2, 2010

  1. Ji

    JizzaBeez The One and Only
    0/47

    Joined:
    Nov 15, 2009
    Messages:
    384
    Likes Received:
    136
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Cerebral Cortex.
    Console:
    Xbox
    Here is an example to make your Forms fade In and fade Out.

    Fade In:
    Code:
    Private Sub FadingInForm()
    
     	Dim iCount As Integer
    
     	For iCount = 0 To 100 Step +10
     	Me.Opacity = iCount / 100
     	Me.Refresh()
     	Threading.Thread.Sleep(50)
     	Next
    
     	Me.Show()
    
    	End Sub
    Fade Out:
    Code:
    Private Sub FadingOutForm()
    
     	Dim iCount As Integer
    
     	For iCount = 100 To 0 Step -10
     	Me.Opacity = iCount / 100
     	Me.Refresh()
     	Threading.Thread.Sleep(50)
     	Next
    
     	Me.Close()
    
    	End Sub
    All you have to do is copy the entire code onto your form's code-view and then simply call it by using someting like a Form_Load or Button_Click Event (or however you want).

    Example: (Fade In on Form_Load)
    Code:
    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
     	FadingInForm()
    
    	End Sub
    Example: (Fade Out by Button_Click)
    Code:
    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
    
     	FadingOutForm()
    
    	End Sub
     

Share This Page

Close