If FlashMode.ToUpperCase = "OFF" Then
Do While(state = 1)
btn.Background = bmp1
If pushed = 1 Then 'pushed variable incremented for each power button push. If pushed first time, do the below
For i1 = 0 To 2
flash.FlashOn
Sleep(2000)
If pushed <> 1 Then Exit ' you wanted immediate, so let's quit in the middle too if something changes
flash.FlashOff
Sleep(500)
Next
Else ' pushed is > 1
For i2 = 0 To 2
flash.FlashOn
Sleep(500)
If pushed <> 2 Then Exit
flash.FlashOff
Sleep(500)
Next
End If
Sleep(1000)
Loop
Else
flash.FlashOff
btn.Background = bmp2
End If