急!!! !!!VB中如何设定声音啊?就例如按了某个按钮判断对错,对就这声音,错就那声音,怎么调啊!?

来源:百度知道 编辑:UC知道 时间:2024/07/16 06:27:58

先添加一个command,然后在这个command添加if语句,代码和你的声音文件名字和来源有关(不过我们多媒体的学VB没你们那么深入的,我们都不用学添加声音或者视频的,而且我们学的VB6.0也未必有这些功能,反正用if语句是绝对OK的)

用API的PlaySound函数

通用
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Sub Command1_Click()
If 对的条件 Then
playwavefile = PlaySound("声音文件名.wav", 0&, lngflags)
ElseIf 错的条件 Then
playwavefile = PlaySound("另一个声音文件名.wav", 0&, lngflags)
End If
End Sub

(声音文件必须是WAV格式,你可以用软件转换格式)

要例子就加425015154