VB中制作按钮声音

添加一个按钮控件,怎么实现点击这个按钮,同时发出提示音?... 添加一个按钮控件,怎么实现点击这个按钮,同时发出提示音? 展开
 我来答
季旭jixu2008
2011-12-13 · TA获得超过253个赞
知道小有建树答主
回答量:267
采纳率:66%
帮助的人:131万
展开全部
处理click时间播放声音就可以了。
追问
什么意思 ?还需要另外添加什么控件或API函数?
追答
模块代码:
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
窗体代码:
Dim FileName As String

Private Function Play_MP3()
FileName = "F:\KuGou\1.mp3 "
mciSendString "Close MM ", 0, 0, 0
mciSendString "Open " & FileName & " Alias MM ", 0, 0, 0
mciSendString "Play MM ", 0, 0, 0
End Function
Private Sub Command1_Click()
FileName = Text1.Text
Play_MP3
End Sub
其中FileName = Text1.Text可以修改为你自己的,FileName = "F:\KuGou\1.mp3 "这里是播放的歌曲。
zgwxm
2011-12-13 · 经典歌曲、名人名家歌曲视频
zgwxm
采纳数:1792 获赞数:21142

向TA提问 私信TA
展开全部
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
End Sub
追问
?
追答
这样不是在按下按钮是发出声音了吗?
如果想播放特定的MP3声音,可以用下面的代码:
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mciSendString "close all", 0, 0, 0
mciSendString "open " & "C:\1.mp3", 0, 0, 0
mciSendString "play " & "C:\1.mp3", 0, 0, 0
End Sub
Private Sub Command2_Click()
'音乐停止播放
mciSendString "close all", 0, 0, 0
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式