VB 加聲音

2010-03-07 6:33 am
我想問係vb度點加聲音ga
e.g.我想整老虎機
當佢贏左錢o既時候
就有d聲似你有d錢跌左落黎
應該點加?

回答 (2)

2010-03-11 8:35 am
✔ 最佳答案
設你有一個1.wav檔,把它放在同一path內,打以下程式,小心大細楷(mp3檔不能播),我在excel VBA OK,我沒有裝設VB6.0,沒法測試,希望也OK

Declare Function playsound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszname As String, ByVal hmodule As Long, ByVal dwflags As Long) As Long
Sub x()
Call playsound(ThisWorkbook.Path & "\1.wav", 0&, &H1)
End Sub


2010-03-11 11:50:06 補充:
VB舉得不好,(ThisWorkbook.Path可能只在試算表生效),設 1.wav 檔放在 C:\

Sub x()
Call playsound("C:\1.wav", 0&, &H1)
End Sub
2010-07-26 9:49 am
可用app.path 阿


收錄日期: 2021-04-13 17:08:46
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20100306000051KK01687

檢視 Wayback Machine 備份