在 Vb 6 中禁用蜂鸣声

发布于 2024-08-23 18:56:53 字数 63 浏览 3 评论 0原文

当我在 VB 6.0 的文本框中按 Ctrl+其他键时,系统会发出蜂鸣声。 如何在 VB 6.0 中禁用此功能?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迟月 2024-08-30 18:56:53

VB 5.0/6.0
'将此代码复制并粘贴到您的 Textbox_KeyPress() 事件中。

If KeyAscii = 13 Then  

    KeyAscii = 0   

End If

来源

VB 5.0/6.0
'Copy and Paste this code in your Textbox_KeyPress() event.

If KeyAscii = 13 Then  

    KeyAscii = 0   

End If

Source

溇涏 2024-08-30 18:56:53

您需要捕获 KeyPress 事件并将 KeyAscii 代码更改为 0(您可以有条件地执行此操作,以仅禁用某些“蜂鸣声情况”)。
与 F.Aquino 的代码非常相似,只是 KeyAscii = 13 用于禁用 Enter 键触发的蜂鸣声。更改条件以符合您的情况。

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.

痕至 2024-08-30 18:56:53
    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

为使代码生效还必须重新启动explorer/系统。

    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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文