怎样才能止住“叮"声?按 Enter 时发出声音 [英] How can to stop the "ding" sound while pressing enter
本文介绍了怎样才能止住“叮"声?按 Enter 时发出声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在按下 Enter 键时停止叮"的声音,但我用它来发送消息.有我的代码:
I need to stop the "ding" sound while pressing enter but I use it to send a message. There is my code:
Private Sub textbox2_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) _
Handles TextBox2.KeyDown
If e.KeyCode = Keys.Enter Then
TextBox3.ReadOnly = True
If TextBox2.Text = ("") Then
Else
Dim PostData = "token=" & TextBox1.Text & "&msg=" & TextBox3.Text & ": " & TextBox2.Text
Dim request As WebRequest = WebRequest.Create("http://url.com/msg.php")
request.Method = "POST"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
TextBox2.Clear()
End If
End If
End Sub
我正在使用另一种声音来通知文本框何时更改,但此 textbox2 用于发送消息,当它使用输入此ding"播放和其他声音一起发送时.
I'm using an another sound to notify when a textbox changed but this textbox2 is for sending messages and when it sends it using enter this "ding" plays and the other sound together.
推荐答案
尝试将 e.Handled
和 e.SuppressKeyPress
设置为 True
.
Try setting e.Handled
and e.SuppressKeyPress
to True
.
Private Sub TextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox2.KeyDown
If e.KeyCode = Keys.Enter Then
' Your code...
e.Handled = True
e.SuppressKeyPress = True
End If
End Sub
这应该会抑制叮"声.
这篇关于怎样才能止住“叮"声?按 Enter 时发出声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文