I am trying to make a form flash colours whilst some other activity takes place, and then stop. I use the following functions to flash the form.

VB Code:
  1. Private Function RunWalkthrough_0_1()
  2.     'Explain the display
  3.     Call FlashForm(frmControlHead)
  4.    'Do stuff.... lalala
  5.     Call StopFlashControl
  6. End Function
  7.  
  8. Public Sub FlashForm(frmForm As Form, Optional ColourFlash = -1)
  9. On Error Resume Next
  10.     'Flash form between two colours every second
  11.     flgFlashControl = True
  12.    
  13.     'Set flash colour and original colour
  14.     Dim OriginalColour As Long, FlashColour As Long
  15.     FlashColour = IIf((ColourFlash < 0), DEFAULT_FLASH_COLOUR, ColourFlash)
  16.     OriginalColour = frmForm.BackColor
  17.    
  18.     'Flash form
  19.     Do While (flgFlashControl)
  20.         DoEvents
  21.         'Swap colours
  22.         If frmForm.BackColor = FlashColour Then
  23.             frmForm.BackColor = OriginalColour
  24.         Else
  25.             frmForm.BackColor = FlashColour
  26.         End If
  27.         'Wait
  28.         PauseMe (50000)
  29.     Loop
  30.    
  31.     'Return form colour
  32.     frmForm.BackColor = OriginalColour
  33. End Sub
  34.  
  35. Public Sub StopFlashControl()
  36.     'Reset flashing flag
  37.     flgFlashControl = False
  38. End Sub
  39.  
  40.  
  41. 'Pause system in a loop temporarily
  42. Public Sub PauseMe(lngPauseDuration As Long)
  43.     Dim i As Long
  44.     Do Until i = lngPauseDuration
  45.         i = i + 1
  46.         DoEvents
  47.     Loop
  48. End Sub

But the code never seems to leave the FlashForm function. StopFlashControl is never callled. Bit of help, please?