I find this particularly useful in an MDI environment where you don't want to keep switching forms to read informationjust make the front form transparent to read the one behind, then fade it in again. Much nicer than Alt+Tab!! Can also be used when quitting programs for a bit of extra class (no pun intended...)
Create a form with two buttonsbtnFadeIn & btnFadeOut and execute the
appropriate function.
Drop in the following code:
---------------------------
Private Function FadeIn()
' attach to BtnFadeIn_Click
Dim start, finish As Double
Dim i As Integer
i = 1
start = Microsoft.VisualBasic.DateAndTime.Timer
finish = start + 2.0
Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
If Me.Opacity < 1.0 Then
Me.Opacity = ((i * 1) / 100)
i = i + 1
Else
Exit Do
End If
Loop
End Function
Private Function FadeOut()
' attach to BtnFadeOut_Click - also Form1_Closing
Dim start, finish As Double
Dim i As Integer
i = 1
start = Microsoft.VisualBasic.DateAndTime.Timer
finish = start + 1.0
Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
If Me.Opacity > 0.25 Then
Me.Opacity = ((100 - (i * 1)) / 100)
i = i + 1
Else
Exit Do
End If
Loop
End Function