Results 1 to 2 of 2

Thread: playing a sound

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    7

    playing a sound

    Hello people,

    i was just wondering if anyone knew how i could play a sound off my programe, i want a sound file to play when a winner on my program gets the jackpot!

    my code atm is

    VB Code:
    1. If TotalWinner6 = 6 Then
    2. MessageBox.Show("Winner!!! MILLIONAIRE!!! for " & objCurrentRow("LastName"))
    3. End If

    Any help on this would be very gratful

    Cheers

    Mikey

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    take a look at the PlaySound Api , here's a quick example i knocked together for you ...
    VB Code:
    1. Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Int32, ByVal dwFlags As Int32) As Int32
    2.     Private Const SND_FILENAME As Int32 = &H20000
    3.  
    4.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    5.         Dim TotalWinner6 As Integer = 6
    6.  
    7.         If TotalWinner6 = 6 Then
    8.             Dim thrd As New Threading.Thread(AddressOf WinnerSound)
    9.             thrd.Start() '/// set a new thread to play the sound file ( to allow the message box to show at the same time as the sound plays )
    10.             MessageBox.Show("we have a winner!")
    11.         End If
    12.  
    13.     End Sub
    14.  
    15.     Private Sub WinnerSound()
    16.         PlaySound("C:\WINDOWS\MEDIA\Windows XP Startup.wav", 0, SND_FILENAME)
    17.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

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