Share via


Visual Basic Reference

BackColor, ForeColor Properties Example

This example resets foreground and background colors randomly twice each second for a form and PictureBox control. To try this example, paste the code into the Declarations section of a form that contains a PictureBox control and a Timer control, and then press F5.

  Private Sub Form_Load ()
   Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer ()
   BackColor = QBColor(Rnd * 15)
   ForeColor = QBColor(Rnd * 10)
   Picture1.BackColor = QBColor(Rnd * 15)
   Picture1.ForeColor = QBColor(Rnd * 10)
End Sub