Reputation: 6244
When I press Ctrl+other keys in a TextBox in VB 6.0, the system plays a beep sound. How can I disable this in VB 6.0?
Upvotes: 1
Views: 4968
Reputation: 1
Private Sub Command1_Click()
'Beep off
Dim res
res = Shell("reg add " + Chr(34) + "HKEY_CURRENT_USER\Control Panel\Sound" + Chr(34) + " /t REG_SZ /v Beep /d no /f", vbHide)
End Sub
Private Sub Command2_Click()
'Beep on
Dim res
res = Shell("reg add " + Chr(34) + "HKEY_CURRENT_USER\Control Panel\Sound" + Chr(34) + " /t REG_SZ /v Beep /d yes /f", vbHide)
End Sub
For code takes effect still must restart explorer/system.
Upvotes: 0
Reputation: 8084
You need to capture the KeyPress event and change the KeyAscii code to 0 (you can do it conditionally, to only disable some of the "beep cases").
Much like F.Aquino's code, only that KeyAscii = 13
is for disabling beeps triggered by the Enter-key. Change the condition to match your case.
Upvotes: 1
Reputation: 9127
VB 5.0/6.0 'Copy and Paste this code in your Textbox_KeyPress() event.
If KeyAscii = 13 Then
KeyAscii = 0
End If
Upvotes: 3