Fade in Fade Out Form in VB.net
  • For Fade in form please follow the Steps

    You need 2 timer controls and 1 button

    First copy this code and paste on your form_load event

      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Opacity = 0
            Timer1.Interval = 20
            Timer1.Enabled = True
            Timer2.Interval = 20
            Timer2.Enabled = False
        End Sub

    Then copy this code and then paste on your timer1_tick event

     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            If Me.Opacity = 1 Then
                Timer1.Stop()
            Else
                Me.Opacity += 0.02
            End If
        End Sub

    Then copy this code and paste in your timer2_tick event

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            If Me.Opacity = 0 Then
                Timer2.Stop()
                End
            Else
                Me.Opacity -= 0.02
            End If
        End Sub

    For Fade out Copy this code and then paste in your button_click event

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If Me.Opacity = 1 Then
                Timer2.Enabled = True
            End If
        End Sub
    hussainroyal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week