Label Animation Zoom-out Fade
Computer Programming is interesting because when you start doing something it will definitely lead to more than that and give you more ideas to try different things all the time. I have started with the Label Animation methods and thought of presenting one or two tricks but we have gone through five different animation methods by now.
A sample image of the Run of the Program is given below:
In this method the Color of each letter of the Employee name is slowly fading away to distance. The size of each letter of the name is getting reduced at each step and the letters are displayed at a fixed time of interval giving it an animated and three dimensional effect.
If you have not tried out the earlier Label animation methods you may take a look at them by visiting the following pages:
Let us try the new method.
- Make a copy of the Employees Form we have used last week with twenty small labels with the Name Property set the with the Values lbl01 to lbl20.
Sample image of the Form is given below for reference:
- Open the Employees Form you have copied in Design View.
- Display the Code Module of the Form (View – -> Code).
- Copy and paste the following VBA Code into the Module, over-writing the existing Code:
Option Compare Database Option Explicit Dim j, txtName, ctrl As Label, i Private Sub Form_Current() Dim t, xRGB As Long, fsize txtName = UCase(Me![first name] & " " & Me![Last name]) fsize = 22 For j = 1 To 20 Set ctrl = Me("lbl" & Format(j, "00")) ctrl.FontSize = fsize ctrl.Caption = "" fsize = fsize - 1 Next xRGB = RGB(10, 10, 10) i = xRGB For j = 1 To Len(txtName) Set ctrl = Me("lbl" & Format(j, "00")) xRGB = xRGB + i ctrl.ForeColor = xRGB ctrl.Caption = Mid(txtName, j, 1) t = Timer Do While Timer < t + 0.1 DoEvents Loop Next End Sub
- Save the Form with the Code and open it in normal view.
- Use the Record Navigation Button and move the record forward or back and watch how the Employee name is displayed on the header of the form.