Click here to Skip to main content
16,006,065 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: SQL query with where clause Pin
Dave Kreskowiak17-Jul-04 7:45
mveDave Kreskowiak17-Jul-04 7:45 
GeneralRe: SQL query with where clause Pin
Steven Campbell17-Jul-04 12:24
Steven Campbell17-Jul-04 12:24 
GeneralRe: SQL query with where clause Pin
Dave Kreskowiak18-Jul-04 8:59
mveDave Kreskowiak18-Jul-04 8:59 
GeneralRe: SQL query with where clause Pin
Steven Campbell18-Jul-04 13:52
Steven Campbell18-Jul-04 13:52 
GeneralRe: SQL query with where clause Pin
Dave Kreskowiak19-Jul-04 2:37
mveDave Kreskowiak19-Jul-04 2:37 
GeneralOpening PDF file separated by pages Pin
franco_8216-Jul-04 19:02
franco_8216-Jul-04 19:02 
GeneralRe: Opening PDF file separated by pages Pin
Mekong River17-Jul-04 4:32
Mekong River17-Jul-04 4:32 
Generalassociate sounds with buttons Pin
samithas16-Jul-04 16:25
samithas16-Jul-04 16:25 
I have a form layed out in Visual Studio .NET Professional, and I have 30 buttons layed out, I have sound files on the hard drive, and I would like to associate those sounds with those buttons.

So when the Sounds.exe is run, and I press the first button then the sound is automatically played.

Is there a way to link the sound to the button?

And also when I build the .exe file is the sound file added to the .exe file?

I am all new to this, and have created some code from a webpage that talked about embedding sounds, so I used the code as you see below :

Class SoundButton
Inherits Button

'API call for playing sounds in memory
Private Declare Function PlaySound Lib "winmm.dll" (ByVal data() As Byte, _
ByVal hMod As IntPtr, ByVal hwFlags As Integer) As Integer
Private Const SND_ASYNC As Integer = &H1 'Play asynchronously
Private Const SND_MEMORY As Integer = &H4 'Play wav in memory

'The .wav will be stored in this byte array
Private Shared ClickSound As Byte()

Shared Sub New()
'Get running assembly name
Dim NameSpc As String = _
Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()
'Look for the button click sound in the resource stream.
'This example has a resource called hello1.wav
Dim WavStrm As IO.Stream = _
Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
NameSpc + "." + "hello1.wav")
'ReDim the byte array to be the size of the embedded .wav
ReDim ClickSound(CType(WavStrm.Length, Integer))
'Load the .wav from the stream into the byte array
WavStrm.Read(ClickSound, 0, Int(CType(WavStrm.Length, Integer)))
End Sub

'Override the OnClick event to play the sound
Protected Overrides Sub OnClick(ByVal ea As EventArgs)
Call PlayWav(ClickSound)
MyBase.OnClick(ea)
End Sub

'Play embedded .wav resource
Public Sub PlayWav(ByVal WavResource As Byte())
PlaySound(WavResource, IntPtr.Zero, SND_ASYNC Or SND_MEMORY)
End Sub
End Class

The hello1.wav file is the file I wanted to play when i ran the app.

If you want to see my source code you can get it here :

h**p://home.pacific.net.au/~jf3000/sounds.zip

Id appreciate any help at all on this, and just let me know how to get the first button going so I know where to take it from there.

You will have to tell me in the most earliest of beginners terms, cos im still trying to understand something ive only just started.

Someone mentioned in a forum to play a sound use this : PlaySound() but that lost me.


samitha
GeneralRe: associate sounds with buttons Pin
Dave Kreskowiak17-Jul-04 7:39
mveDave Kreskowiak17-Jul-04 7:39 
GeneralHelp with coding for message box. Pin
superprogrammingdude16-Jul-04 6:02
superprogrammingdude16-Jul-04 6:02 
GeneralRe: Help with coding for message box. Pin
crazy-weasel16-Jul-04 7:06
crazy-weasel16-Jul-04 7:06 
GeneralRe: Help with coding for message box. Pin
superprogrammingdude16-Jul-04 8:40
superprogrammingdude16-Jul-04 8:40 
QuestionHow to Create Dynamic Toolbar in VB6.0 Pin
Member 119551216-Jul-04 5:18
Member 119551216-Jul-04 5:18 
AnswerRe: How to Create Dynamic Toolbar in VB6.0 Pin
Dave Kreskowiak16-Jul-04 10:20
mveDave Kreskowiak16-Jul-04 10:20 
GeneralCrystal Report viewer Navigation bar problem Pin
spn16-Jul-04 1:20
spn16-Jul-04 1:20 
QuestionHow to set Align property to User ActiveX control Pin
Member 119551215-Jul-04 23:33
Member 119551215-Jul-04 23:33 
GeneralCrystal reports chart Axis / series 'wrong way round' Pin
Martin Gibson15-Jul-04 21:56
Martin Gibson15-Jul-04 21:56 
GeneralInput string was not in a correct format Pin
DotNet15-Jul-04 18:33
DotNet15-Jul-04 18:33 
GeneralRe: Input string was not in a correct format Pin
Dave Kreskowiak16-Jul-04 1:03
mveDave Kreskowiak16-Jul-04 1:03 
GeneralEnableVisualStyles Pin
GregOsborne15-Jul-04 6:39
GregOsborne15-Jul-04 6:39 
GeneralRe: EnableVisualStyles Pin
Dave Kreskowiak16-Jul-04 1:03
mveDave Kreskowiak16-Jul-04 1:03 
GeneralRe: EnableVisualStyles Pin
The Man from U.N.C.L.E.19-Jul-04 6:50
The Man from U.N.C.L.E.19-Jul-04 6:50 
GeneralGet URL from hyperlink text Pin
Vyyk Drago15-Jul-04 4:45
sussVyyk Drago15-Jul-04 4:45 
GeneralRe: Get URL from hyperlink text Pin
Dave Kreskowiak17-Jul-04 7:12
mveDave Kreskowiak17-Jul-04 7:12 
GeneralRe: Get URL from hyperlink text Pin
Vyyk Drago17-Jul-04 8:57
sussVyyk Drago17-Jul-04 8:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.