By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,587 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,587 IT Pros & Developers. It's quick & easy.

Stopping Default Sound from Playing

P: n/a
I have an application that is designed for using with a bar code scanner. I
want the user to know that the scan was complete and the data was entered, so
I am playing a system sound after data entry. The data is being put into a
text box, and a Return is sent after the data. I use the keypress event to
capture the Return, and save the data. Then, I play the system sound, clear
the text box, and set the focus back to the text box for the next entry.
When I do that, somewhere along the way, the default sound also plays. This
is disrupting my Exclamation sound, and not giving the audible notification
that I want. If there is a problem with the input for some reason, then I
have a message box popping up, and it gives the default sound also. Changing
the default sound does no good, as it would change the one being played when
the message box pops up. The user will not have anything to distinguish
between the good input and the bad input. What event is firing the default
sound, and can I turn it off, so that my Exclamation sound can be heard, or
can I set it to the Exclamation sound?
May 9 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Wed, 9 May 2007 12:04:02 -0700, Vernon Peppers wrote:
I have an application that is designed for using with a bar code scanner. I
want the user to know that the scan was complete and the data was entered, so
I am playing a system sound after data entry. The data is being put into a
text box, and a Return is sent after the data. I use the keypress event to
capture the Return, and save the data. Then, I play the system sound, clear
the text box, and set the focus back to the text box for the next entry.
When I do that, somewhere along the way, the default sound also plays. This
is disrupting my Exclamation sound, and not giving the audible notification
that I want. If there is a problem with the input for some reason, then I
have a message box popping up, and it gives the default sound also. Changing
the default sound does no good, as it would change the one being played when
the message box pops up. The user will not have anything to distinguish
between the good input and the bad input. What event is firing the default
sound, and can I turn it off, so that my Exclamation sound can be heard, or
can I set it to the Exclamation sound?
For your second problem (exclamation sound when the MessageBox is shown),
simply do not show a MessageBox if you do not want any sound to play.
Instead, create your own Form (you can make it look like the standard
MessageBox and implement static methods to show it if you want, it's all
straightforward) and show that instead. It won't play any sound.

Regarding your first problem, it isn't clear from your description why the
exclamation sound is played. Find out what exactly causes the default sound
to play and don't do that (just as with the MessageBox, find an alternative
way of doing whatever you want to do).
May 10 '07 #2

P: n/a
The only thing that I can find is that the sound plays when I exit the
KeyPress event method. I have stepped my code, and I get no default sound
until I execute the Exit Sub line. I have no idea what is causing the
default sound.

"Mehdi" wrote:
On Wed, 9 May 2007 12:04:02 -0700, Vernon Peppers wrote:
I have an application that is designed for using with a bar code scanner. I
want the user to know that the scan was complete and the data was entered, so
I am playing a system sound after data entry. The data is being put into a
text box, and a Return is sent after the data. I use the keypress event to
capture the Return, and save the data. Then, I play the system sound, clear
the text box, and set the focus back to the text box for the next entry.
When I do that, somewhere along the way, the default sound also plays. This
is disrupting my Exclamation sound, and not giving the audible notification
that I want. If there is a problem with the input for some reason, then I
have a message box popping up, and it gives the default sound also. Changing
the default sound does no good, as it would change the one being played when
the message box pops up. The user will not have anything to distinguish
between the good input and the bad input. What event is firing the default
sound, and can I turn it off, so that my Exclamation sound can be heard, or
can I set it to the Exclamation sound?

For your second problem (exclamation sound when the MessageBox is shown),
simply do not show a MessageBox if you do not want any sound to play.
Instead, create your own Form (you can make it look like the standard
MessageBox and implement static methods to show it if you want, it's all
straightforward) and show that instead. It won't play any sound.

Regarding your first problem, it isn't clear from your description why the
exclamation sound is played. Find out what exactly causes the default sound
to play and don't do that (just as with the MessageBox, find an alternative
way of doing whatever you want to do).
May 10 '07 #3

P: n/a
On Thu, 10 May 2007 09:20:00 -0700, Vernon Peppers wrote:
The only thing that I can find is that the sound plays when I exit the
KeyPress event method. I have stepped my code, and I get no default sound
until I execute the Exit Sub line. I have no idea what is causing the
default sound.
If you're using a single-line textbox (ie. Multiline is set to false), then
pressing the Return key in the text box will cause Windows to emit a beep,
presumably to inform the user that they can't create new lines in the text
box.

It is not very clear what you are doing with your text box. From your
original description, it looks like the user is not actually typing
anything in the text box but that you're reading data using a bar code
reader, populating the textbox with the read data then insterting a Return
caracter at the end. And on top of that you're using the keypress event to
do I don't know what. I have trouble understanding what you are trying to
achieve. Why do you need to insert a Return caracter at the end of the data
in the text box? This caracter can not be seen anyway since it's a
single-line textbox so what's the point of adding it? If you don't add the
Return at the end, Windows won't beep.
May 11 '07 #4

P: n/a
The barcode scanner acts like a keyboard. The data is entered by the barcode
scanner. To all intents and purposes, the program can not tell the
difference between a scan from the barcode scanner, and input from the
keyboard. The Return character is sent by the barcode scanner to indicate
that the barcode is complete. If it is the Return that is causing the
problem, then I possibly could change the Return character to something else,
so that I could test for that character instead. The Return currently tells
the program that the barcode is complete, and to process that barcode, by
creating a new row in the data table, and populating the row with the
barcode, and other data from the input screen.

Since I don't have the scanner in my possession to reprogram it, is there
any way to turn this beep off?

"Mehdi" wrote:
On Thu, 10 May 2007 09:20:00 -0700, Vernon Peppers wrote:
The only thing that I can find is that the sound plays when I exit the
KeyPress event method. I have stepped my code, and I get no default sound
until I execute the Exit Sub line. I have no idea what is causing the
default sound.

If you're using a single-line textbox (ie. Multiline is set to false), then
pressing the Return key in the text box will cause Windows to emit a beep,
presumably to inform the user that they can't create new lines in the text
box.

It is not very clear what you are doing with your text box. From your
original description, it looks like the user is not actually typing
anything in the text box but that you're reading data using a bar code
reader, populating the textbox with the read data then insterting a Return
caracter at the end. And on top of that you're using the keypress event to
do I don't know what. I have trouble understanding what you are trying to
achieve. Why do you need to insert a Return caracter at the end of the data
in the text box? This caracter can not be seen anyway since it's a
single-line textbox so what's the point of adding it? If you don't add the
Return at the end, Windows won't beep.
May 11 '07 #5

P: n/a
On Fri, 11 May 2007 08:57:00 -0700, Vernon Peppers wrote:
The barcode scanner acts like a keyboard. The data is entered by the barcode
scanner. To all intents and purposes, the program can not tell the
difference between a scan from the barcode scanner, and input from the
keyboard. The Return character is sent by the barcode scanner to indicate
that the barcode is complete. If it is the Return that is causing the
problem, then I possibly could change the Return character to something else,
so that I could test for that character instead. The Return currently tells
the program that the barcode is complete, and to process that barcode, by
creating a new row in the data table, and populating the row with the
barcode, and other data from the input screen.

Since I don't have the scanner in my possession to reprogram it, is there
any way to turn this beep off?
Alright, I get it now. Well, I see 2 solutions:

- turning the beep off. There are hacks that allow you to turn it off
without modifying the system sound settings. I did it a while ago though
can't remember exactly what I did. However if you search Google Groups for
Textbox Return (or Enter) Beep, you'll find a lot of discusions about this.
You shouldn't have too much troubles switching off the beep.

- Set a default Accept button on your form. If your form has a default
Accept button, pressing Enter while in the textbox will press this button
instead of doing nothing and beeping. So you could maybe have an OK button
set as the Accept button of your form which, when pressed, would add the
new data in the datatable. Actually, using an Accept button will introduce
other problems (it will by default automatically set the DialogResult value
of your form which will cause it to close if it has been shown modally) so
if you've got your program already done and working the way you want the
best solution would probably be to just switch off the beeping sound
following Google Groups suggestions.
May 11 '07 #6

P: n/a
Thanks for the tip. Searching as you suggesting yielded the suggestion to
add the following line to my code that handled the Return keypress:

e.handled=True

That did it!

"Mehdi" wrote:
On Fri, 11 May 2007 08:57:00 -0700, Vernon Peppers wrote:
The barcode scanner acts like a keyboard. The data is entered by the barcode
scanner. To all intents and purposes, the program can not tell the
difference between a scan from the barcode scanner, and input from the
keyboard. The Return character is sent by the barcode scanner to indicate
that the barcode is complete. If it is the Return that is causing the
problem, then I possibly could change the Return character to something else,
so that I could test for that character instead. The Return currently tells
the program that the barcode is complete, and to process that barcode, by
creating a new row in the data table, and populating the row with the
barcode, and other data from the input screen.

Since I don't have the scanner in my possession to reprogram it, is there
any way to turn this beep off?

Alright, I get it now. Well, I see 2 solutions:

- turning the beep off. There are hacks that allow you to turn it off
without modifying the system sound settings. I did it a while ago though
can't remember exactly what I did. However if you search Google Groups for
Textbox Return (or Enter) Beep, you'll find a lot of discusions about this.
You shouldn't have too much troubles switching off the beep.

- Set a default Accept button on your form. If your form has a default
Accept button, pressing Enter while in the textbox will press this button
instead of doing nothing and beeping. So you could maybe have an OK button
set as the Accept button of your form which, when pressed, would add the
new data in the datatable. Actually, using an Accept button will introduce
other problems (it will by default automatically set the DialogResult value
of your form which will cause it to close if it has been shown modally) so
if you've got your program already done and working the way you want the
best solution would probably be to just switch off the beeping sound
following Google Groups suggestions.
May 11 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.