CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Posts
    18

    What is the error?

    The program is design to play sound.
    when I select a .wav or .midi file to play,there is an error that is "the function is undeclared",but why?

    Is there any errors when I use the playsound(...)function?

    the code is as follow:

    Private Sub Drive1_Change()
    On Error GoTo check
    Dir1.Path = Drive1.Drive
    Exit Sub
    check:
    MsgBox "The driver is unavailable!"
    Drive1.Drive = "c:\"
    Resume Next
    End Sub

    Private Sub Dir1_Change()
    File1.Path = Dir1.Path
    End Sub
    Private Sub Command1_Click()
    Dim filename As String
    Dim Error As Long
    If Right(File1.Path, 1) = "\" Then
    filename = File1.Path + File1.filename
    Else
    filename = File1.Path + "\" + File1.filename
    End If
    Error = PlaySound(filename, 0, SND_FILENAME Or SND_SYNC)
    End Sub



  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: What is the error?

    you need to declare it cause it is API, like this

    Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long




    HTH

    cksiow
    http://vblib.virtualave.net - share our codes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured