Click here to Skip to main content
15,894,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi again experts.The code to make my form2 fadesIn looks like a pop-up screen. I want to make it smooth same like when its fading out.

VB
Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.Opacity = 0.99

        ''fadeIn
        Dim iCount As Integer

        For iCount = 90 To 10 Step -5
            Me.Opacity = iCount / 100
            Me.Refresh()
            Threading.Thread.Sleep(100)
            Me.Opacity = 0.99
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ''fadeOut
        Dim iCount As Integer

        For iCount = 90 To 10 Step -10
            Me.Opacity = iCount / 100
            Me.Refresh()
            Threading.Thread.Sleep(50)
        Next

        Me.Close()
    End Sub
End Class
Posted

1 solution

In your Form2_Load event your loop is going in the wrong direction ... you need to start with low opacity and work upwards ...
VB
'Me.Opacity = 0.99 ' Get rid of this
''fadeIn
Dim iCount As Integer
For iCount = 10 To 90 Step 5
 
Share this answer
 
Comments
akosisugar 3-Jun-13 5:21am    
geee! now its perfect! thank you sir. such a big help for a noob like me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900