Hi, and welcome to my first tiny Visual Basic.Net tutorial.
In this tutorial i will show you how to let a form fade in and out.
First off all, you need to open Microsoft Visual Basic 2008 Express Edition and start a new Windows Form Application.
Now that you have made your form,
you will need to place a button. (for the fade out effect)
After you are done, your form should look like this:
Now double click your form and you should get this:
Now you have to put
Code:
Dim fadeinout As Double
For fadeinout = 0 To 1.01 Step 0.01
Me.Opacity = fadeinout
Next
between
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
so you should get this:
Now press the 'Debug Button' to see the fade in effect:
and now your Form1 should fade in when you start it.
Now lets do the fade out effect with the button.(This can also be done for closing the form, but ill stick with the button for now)
You should have the folowing code atm:
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fadeinout As Double
For fadeinout = 0 To 1.01 Step 0.01
Me.Opacity = fadeinout
Next
End Sub
End Class
Now double click your Button1 and this should appear
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
Put
Code:
Dim fadeout As Double
For fadeout = 1 To 0 Step -0.001
Me.Opacity = fadeout
Next
Between:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
And now you should have:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fadeout As Double
For fadeout = 1 To 0 Step -0.001
Me.Opacity = fadeout
Next
End Sub
End Class
Now press the debug button again.
And now your form will fade in and out!
I hope this tutorial helped you.
