0

im trying to check whether a sound file has ended using the windows MCI API in vb.net but it keeps coming up with an invalid device name (263 - MCIERR_INVALID_DEVICE_NAME), is it because of my syntax or some other error?

  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

1 Answers1

0

Why is Target defined as an integer and then added as a null string? Is Microsoft.VisualBasic.Right(ButtonName, 2) actually returning a string that was defined as an integer? Maybe redefine Target as a string then check to make sure it is not a null string before passing it to mciSendString.