Random text color by VBA

You can make the text look more nice by setting the text to change more than ten colors. It means you  random color of the text. You can do it by following the steps below:

- Create a new form

- Drag and drop a label control on form

- Write words or phrase which you want

- Then apply the VBA code below to the form code module:

Option Explicit
Option Compare Database
Dim i As Integer

Private Sub Form_Load()
   TimerInterval = 500
   i = 0
End Sub

Private Sub Form_Timer()
   If i < 15 Then
     i = i + 1
     Label0.ForeColor = QBColor(i)
   Else: i = 0
   End If
End Sub

OR

Private Sub Form_Timer()
  Label0.ForeColor = QBColor(Rnd * 15)
End Sub


Posted by: ly | post date: 11-18-2012 | Subject: VBA for MS Access

Access tip



    This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
    C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.