danucalovj

Fade In/Out Routine

Jan 5th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.13 KB | None | 0 0
  1. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  2.      e.Cancel = True
  3.      Me.Opacity = 1
  4.      Dim tmr As New Timer
  5.      tmr.Interval = 100
  6.      tmr.Start()
  7.      AddHandler tmr.Tick, AddressOf fadeOUT_tick
  8.  End Sub
  9.  Private Sub fadeOUT_tick(ByVal sender As Object, ByVal e As System.EventArgs)
  10.      Me.Opacity -= 0.1
  11.      Label1.Text = Me.Opacity.ToString
  12.      If Me.Opacity = 0 Then
  13.          CType(sender, Timer).Stop()
  14.          Me.Dispose()
  15.      End If
  16.  End Sub
  17.  
  18.  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  19.      Me.Opacity = 0
  20.      Dim tmr As New Timer
  21.      tmr.Interval = 100
  22.      tmr.Start()
  23.      AddHandler tmr.Tick, AddressOf fadeIN_tick
  24.      If Me.Opacity >= 1 Then
  25.          MessageBox.Show("Form Loaded")
  26.          tmr.Stop()
  27.      End If
  28.  End Sub
  29.  Private Sub fadeIN_tick(ByVal sender As Object, ByVal e As System.EventArgs)
  30.      Me.Opacity += 0.1
  31.      Label1.Text = Me.Opacity.ToString
  32.      If Me.Opacity = 1 Then
  33.          CType(sender, Timer).Stop()
  34.      End If
  35.  End Sub
Advertisement
Add Comment
Please, Sign In to add comment