Home > How-To Library > Forms

How to fade the form away when the user closes it.

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
Private Sub Command1_Click() FadeScreen Me, "tl" End Sub Public Function FadeScreen(frm As Form, strWhichWay As String) Dim sngVertSize As Single Dim sngHorSize As Single Dim sngMoveRight As Single Dim sngMoveTop As Single Dim i As Integer Const cstStep = 100 sngVertSize = frm.Width / cstStep Select Case UCase(strWhichWay) Case "TR" 'fade to top right sngMoveRight = frm.Height / cstStep sngHorSize = sngMoveRight Case "BL" 'fade to bottom left sngMoveTop = frm.Height / cstStep sngVertSize = sngMoveTop sngHorSize = frm.Height / cstStep Case "BR" 'fade to bottom right sngMoveTop = frm.Height / cstStep sngVertSize = sngMoveTop sngMoveRight = frm.Height / cstStep sngHorSize = frm.Height / cstStep Case Else 'default to top left if you put something else in sngHorSize = frm.Height / cstStep 'size of horizontal steps End Select For i = 1 To cstStep - 1 frm.Move frm.Left + sngMoveRight, frm.Top + sngMoveTop, _ frm.Width - sngHorSize, frm.Height - sngVertSize Next Unload frm End Function

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.