Fade Animation
- Hello,
Can i fade a form when i click on button?
Answers
- Loop, and lower the Opacity of your form until it is invisible....
Do Until Me.Opacity = 0 Me.Opacity -= 0.005 Application.DoEvents() Loop Me.Close()
Regards,
Wayne Taylor- Marked As Answer byVB Addictive Friday, November 14, 2008 7:17 AM
All Replies
- Loop, and lower the Opacity of your form until it is invisible....
Do Until Me.Opacity = 0 Me.Opacity -= 0.005 Application.DoEvents() Loop Me.Close()
Regards,
Wayne Taylor- Marked As Answer byVB Addictive Friday, November 14, 2008 7:17 AM
- Hi,
You can fade a form by changing the opacity using loop.
another method is using javascript and fade, check this sample code.<script language="JavaScript"><!-- function fader(object,text) { setTimeout("fade('" + object + "','" + text + "','#000000')",100); setTimeout("fade('" + object + "','" + text + "','#333333')",200); setTimeout("fade('" + object + "','" + text + "','#666666')",300); setTimeout("fade('" + object + "','" + text + "','#999999')",400); setTimeout("fade('" + object + "','" + text + "','#cccccc')",500); setTimeout("fade('" + object + "','" + text + "','#ffffff')",600); } function fade(object,text,color) { if (document.layers) { document.layers[object].document.open(); document.layers[object].document.write('<font color="' + color + '">' + text + '<\/font>'); document.layers[object].document.close(); } else if (document.all) { document.all[object].style.color = color; } } //--></script> <form> <input type="button" value="Click me" onClick="fader('myLayer1','This is some text')"> </form> <div id="myLayer1" style="position:absolute"> This is some text </div>
vijay - too fast too fast...how do i make it slower ? thanks
Smile, Joshua Siew - This is an old thread
Please post a new thread :) - Make the decrement smaller
Do Until Me.Opacity = 0 Me.Opacity -= 0.0005 Application.DoEvents() Loop Me.Close() - Use a timer but if you fade it too much you won't be able to click on any of the controls .
Private Sub Form1_Load( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Interval = 100 Timer1.Enabled = True End Sub Private Sub Timer1_Tick( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Timer1.Tick If Me.Opacity < 0.5 Then Timer1.Enabled = False End If Me.Opacity -= 0.01 End Sub
coding for fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
Please format the code in your posts with the
button . Makes it easier to read .


