主题:菜鸟请教:能不能把做好的VB程序加上背景音乐呀?
大懒猫
[专家分:220] 发布于 2008-12-07 09:31:00
能不能把做好的VB程序加上背景音乐呀?比如:手上现有《铃儿响钉铛》的歌曲
回复列表 (共19个回复)
11 楼
大懒猫 [专家分:220] 发布于 2008-12-16 10:10:00
[quote]额的个神啊~~~
估计楼主还不知道有API这么一回事?
在代码里添加函数声明:
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
[/quote]
额的个神啊~~~估计GG你还不知道有菜鸟这么一回事?!
我有加呀,提示“编译错误:在end sub、end function或end属性后面只能出现注释”,我反复检查了,没有多余的end sub呀!
12 楼
大懒猫 [专家分:220] 发布于 2008-12-16 10:13:00
[quote]那要看原来的程序是不是你做的![/quote]咬你哟!
[em27]
13 楼
tanchuhan [专家分:15140] 发布于 2008-12-16 11:28:00
[quote][quote]额的个神啊~~~
估计楼主还不知道有API这么一回事?
在代码里添加函数声明:
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
[/quote]
额的个神啊~~~估计GG你还不知道有菜鸟这么一回事?!
我有加呀,提示“编译错误:在end sub、end function或end属性后面只能出现注释”,我反复检查了,没有多余的end sub呀![/quote]
放在类内部的话,API声明前面加上Private
API声明要放在所有过程/函数之前。
新建一工程,粘贴以下代码:
[code=c]
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 Const MUSIC_PATH = "http://218.204.255.52:8100//uploads/diary/200804/21195114664.mp3"
Private Sub Form_Load()
Call mciSendString("OPEN " & MUSIC_PATH & " ALIAS MyMusic", vbNullString, 0, 0)
Call mciSendString("PLAY MyMusic", vbNullString, 0, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call mciSendString("CLOSE MyMusic", vbNullString, 0, 0)
End Sub
[/code]
如果你的网速快,应该很快就听得到音乐了。
14 楼
天天学习 [专家分:4570] 发布于 2008-12-16 20:58:00
[quote]提示“编译错误:在end sub、end function或end属性后面只能出现注释”[/quote]
[quote]API声明要放在所有过程/函数之前。[/quote]
15 楼
大懒猫 [专家分:220] 发布于 2008-12-28 17:56:00
[quote新建一工程,粘贴以下代码:
[code=c]
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 Const MUSIC_PATH = "http://218.204.255.52:8100//uploads/diary/200804/21195114664.mp3"
Private Sub Form_Load()
Call mciSendString("OPEN " & MUSIC_PATH & " ALIAS MyMusic", vbNullString, 0, 0)
Call mciSendString("PLAY MyMusic", vbNullString, 0, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call mciSendString("CLOSE MyMusic", vbNullString, 0, 0)
End Sub
[/code]
如果你的网速快,应该很快就听得到音乐了。[/quote]
太感谢了!
[em32]
16 楼
bcahzvip [专家分:6040] 发布于 2008-12-28 23:53:00
= =;只要加上就行了?
我还以为是嵌入.
17 楼
alfa52374 [专家分:0] 发布于 2009-03-27 23:44:00
这回我也学到不少东西~
18 楼
hp039 [专家分:0] 发布于 2009-04-23 11:05:00
等了好久都听不到音乐··
真是学了不少,虽然看不懂·呵呵
19 楼
zj_jk [专家分:0] 发布于 2009-06-18 00:40:00
谢谢了!非常感谢
我来回复