Flashing Image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wayneyh
    New Member
    • Mar 2008
    • 67

    #1

    Flashing Image

    Hi all

    I have a chechbox and if it is unchecked i want an image to flash on and off.
    I know i have to use the OnTimer but not sure how to code the check box and image together through it. Can anyone please help.

    Regards

    Wayne
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. Assume your Check Box is named chkImage and your Image Control is named imgTest.
    2. Place an Image into the Image Control.
    3. Set the Form's Timer Interval Interval to 1000 (1 second).
    4. Copy and Paste the following code into the Timer() Event (On Timer) Property of the Form:
    5. If the Check Box is checked, the Image will flash every second. Vary the Timer Interval (1000) should you desire more or less frequent flashing.
    6. Here is goes:
      Code:
      Private Sub Form_Timer()
      Static lngCounter As Long
      
      lngCounter = lngCounter + 1
      
      If Me![chkImage].Value Then
        If lngCounter Mod 2 = 0 Then
          Me![imgTest].Visible = True
        Else
          Me![imgTest].Visible = False
        End If
      Else
        Me![imgTest].Visible = False
        
      If lngCounter = 2147000000 Then lngCounter = 1
      End If
      End Sub

    Comment

    • Wayneyh
      New Member
      • Mar 2008
      • 67

      #3
      Thanks ADezii

      That worked great. I had similar code, just wrong way round.

      Thanks

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by Wayneyh
        Thanks ADezii

        That worked great. I had similar code, just wrong way round.

        Thanks
        You are quite welcome.

        Comment

        Working...