devxlogo

Funk Up Your Forms with Fading

I find this particularly useful in an MDI environment where you don’t want to keep switching forms to read information?just 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 buttons?btnFadeIn & btnFadeOut and execute theappropriate 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   LoopEnd FunctionPrivate 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   LoopEnd Function

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Seven Service Boundary Mistakes That Create Technical Debt

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.