Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing for Keypress within a Loop

Status
Not open for further replies.

StuGreentree

IS-IT--Management
Dec 31, 2001
8
US
I am currently adding a visual & audible alarm to a form I have created. The alarm is event driven and I am searching for a way to turn it off. I have tried both the getKeyState and GetAsyncKeyState, but it will not respond to either except in Debug Mode. I have enclosed the general code I have been using to invoke the alarm. Any help would be appreciated. Thanks.....]

Private Sub Text0_KeyPress(KeyAscii As Integer)
Dim Keystate As Integer, Flag as Boolean
Flag = True
Do While Flag
Text0.Value = "ALERT!!! Account is Overdrawn"
Text0.BackColor = RGB(255, 0, 0)
Text0.ForeColor = RGB(0, 0, 0)
Call PlaySound("Sprngbng.wav", 0, &H1) 'WIN32 API Call
Me.Repaint
For Y = 1 To 7000000: Next Y
Text0.BackColor = RGB(192, 192, 192)
Text0.ForeColor = RGB(255, 0, 0)
Me.Repaint
For Y = 1 To 7000000: Next
Keystate = GetAsyncKeyState(vbKeySpace)
If Keystate > 0 Then
Flag = False
End If
Loop
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top