问题描述
我是使用Microsoft Visual Basics的新手,经过搜索后,我似乎仍然找不到解决此编译错误的方法
Private Sub Form_Open(Cancel As Integer)
PlaySound (N:\Computing\ISDD\Chime.wav)
End Sub
它带有一个“错误:列表分隔符或)的编译错误消息,并在代码的第2行中突出显示冒号。抱歉,如果这很容易解决,我只是不明白问题出在哪里,我们将不胜感激
解决方法
尝试一下:
Private Sub Form_Open(Cancel As Integer)
PlaySound "N:\Computing\ISDD\Chime.wav"
End Sub
您缺少两个双引号。
,在模块中定义API调用(apisndPlaySound api调用),然后像这样包装函数PlaySound:
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String,ByVal snd_async As Long) As Long
Public Function PlaySound(ByVal sWav As String)
apisndPlaySound sWav,1
End Function
然后在OnOpen事件上将其称为:
PlaySound "N:\..."
不带括号,否则它将尝试返回一个值。还有双引号。