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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sound with ENTER

Status
Not open for further replies.

reneford

Programmer
Dec 16, 2004
149
CA
I can prevent the "beep" sound when pressing "ENTER" and execute the code on a given button (Just set the propertie "Default" of the button to True.).

But if the button is disabled, how can I prevent the beep sound? Is it possible?

I explain:
When the button in my program is disabled, If I want that the button become enabled again, we have to press ENTER on a TextBox.
 
To Turn off the beep, create a "KeyPress" event for the textbox, and enter this code

if keyascii=13 then
keyascii=0
'do whatever you wanted
end if

by resetting the keyascii (the ascii value of the keypress) you'll eliminate the beep.
 
errr.... That's what the referred thread says!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
heh... that looks familiar...
SonOfEmidec1100 said:
Another way to stop the beep, if you dont want to use the default action.

Code:
Private Sub Text3_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    keyascii=0
    Recherche_Click
  End If
End Sub

from bjd4jc's link (Thread222-940623)

I suppose in this case, if you don't want it to execute the code if the button is disabled, you could do this:

Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    KeyAscii = 0
    [b]If Command1.Enabled Then Command1_Click[/b]
  End If
End Sub

That way if the button is enabled, it will (functionally) click it when enter is pressed, and not if it is disabled, but the program will not beep...


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
oops... (forgot the end quote tag)

should be:
SonOfEmidec1100 said:
Another way to stop the beep, if you dont want to use the default action.


Code:
Private Sub Text3_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    keyascii=0
    Recherche_Click
  End If
End Sub

looks like you beat me to it, johnwm ;-)


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top