我正在尝试检查一个声音文件是否已经结束使用vb.net中的windows MCI API,但它一直出现一个无效的设备名称(263 - MCIERR_INVALID_DEVICE_NAME),是因为我的语法或一些其他错误?
Public Sub CheckAndPlay(ButtonName As String)
Dim Target As Integer
Dim Position As String = Space(256)
Dim Length As String = Space(256)
Target = Microsoft.VisualBasic.Right(ButtonName, 2)
w = mciSendString("status " & Target & " position", Position, 256, 0)
w = mciSendString("status " & Target & " length", Length, 256, 0)
If Val(Position) = Val(Length) - 10 Or Val(Length) = Nothing Or Val(Position) = 0 Or Val(Position) = Nothing Then
w = mciSendString("play " & ButtonName, Nothing, 0, 0)
End If
End Sub发布于 2017-01-22 09:46:01
为什么Target被定义为整数,然后添加为空字符串?Microsoft.VisualBasic.Right(ButtonName,2)实际上返回的是一个定义为整数的字符串吗?也许可以将目标重新定义为字符串,然后在将其传递给mciSendString之前检查以确保它不是空字符串。
https://stackoverflow.com/questions/37882763
复制相似问题