Advertisement
tomjerry741

create a FadeIn & FadeOut to your form in vb 2010-2012

Mar 27th, 2012
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.78 KB | None | 0 0
  1. create new project in vb 2010
  2. under soluation ur project
  3. " i mean your project"
  4. then right-click on "name ur project form"
  5. then sellect Add
  6. then sellect Add Module
  7. when code screen opened
  8. write this code bettwen
  9. Module Module1
  10.  
  11. End Module
  12. -----------------------------------------------------------------------------
  13. Module Module1
  14. Public Sub fadein()
  15.         Dim fade As Double
  16.         For fade = 0.0 To 1.1 Step 0.1
  17.             Form1.Opacity = fade
  18.             Form1.Refresh()
  19.             Threading.Thread.Sleep(1000)
  20.         Next
  21.     End Sub
  22.  
  23.     Public Sub fadeout()
  24.         Dim fade As Double
  25.         For fade = 1.1 To 0.0 Step -0.1
  26.             Form1.Opacity = fade
  27.             Form1.Refresh()
  28.             Threading.Thread.Sleep(1000)
  29.         Next
  30.     End Sub
  31. End Module
  32. -------------------------------
  33. then click Save all
  34. ---------------------------
  35. return to your form application
  36. then
  37. double-click on ur form
  38. then
  39. delete every thing thire then
  40.  
  41. in code screen write this code
  42. ----------------------------------------------------
  43. Public Class Form1
  44.     ' this case for formclosing
  45.     ' i mean that when user close your application
  46.     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  47.         fadeout()
  48.     End Sub
  49.     ' you can add opacity "glass effect to your form if you write this
  50.     ' me.opacity=0.8 as below
  51.  
  52.     ' this case for formLoad
  53.     ' i mean that when user open your application
  54.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  55.         fadein()
  56.         Me.Opacity = 0.8
  57.     End Sub
  58. End Class
  59. --------------------------------
  60. thanx
  61. good bye
  62. tomjerry741@yahoo.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement