VB写个程序单击COMMAND1就唱选中的歌

来源:百度知道 编辑:UC知道 时间:2024/06/22 23:55:30
如题 谢谢
就是在电脑上加入MP3路径到VB text1.text里后单击Command1就唱这首歌歌

播放资源文件文件中的声音
VB 提供的方法使我们可以很容易地使用资源文件中的字符、图片等资源。
我们可以用以下方法播放资源文件中的 wav 声音:
首先,在你的资源文件的源文件 (RC) 文件加入下面一行:
MySound WAVE c:\music\vanhalen.wav
然后将其编译为 RES 文件。最后使用下面的声明及代码:
Private Declare Function PlaySound Lib _ "winmm.dll" Alias "PlaySoundA" (
_ ByVal lpszName As String, _ ByVal hModule As Long, _ ByVal dwFlags As Long) As Long
Private Const SND_ASYNC& = &H1
Private Const SND_NODEFAULT& = &H2
Private Const SND_RESOURCE& = &H40004
Dim hInst As Long
Dim sSoundName As String
Dim lFlags As Long
Dim lRet As Long
Private Sub Command1_Click()
hInst = App.hInstance
sSoundName = "MySound"
lFlags = SND_RESOURCE + SND_ASYNC + _ SND_NODEFAULT
lRet = PlaySound(sSoundName, hInst, lFlags)
End Sub

mark一下以后来学习。

你说的选中是窗体上的列表吗?

a