Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Play sound Automatically in VB.net
Options
-
03-04-2006 2:01pmHi
I am doing a project in Vb.net and I was trying to work with this code I was hoping for some help to get the errors out of the project and play the song automatically when the project starts/click on different form.I also want to run a different sound when I click on the a different form on in the same project.I am going about it the right way.
I tried to upload but got an error.If some one thinks they can help me maybe I can email or pm them the project , any way the code of the main page is :
Public Class FrmParent
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents Mnuarrested As System.Windows.Forms.MenuItem
Friend WithEvents MnuSimpson As System.Windows.Forms.MenuItem
Friend WithEvents Mnu24 As System.Windows.Forms.MenuItem
Friend WithEvents Mnuexit As System.Windows.Forms.MenuItem
Friend WithEvents MnuWeb As System.Windows.Forms.MenuItem
Friend WithEvents MnuVideo As System.Windows.Forms.MenuItem
Friend WithEvents MnuFile As System.Windows.Forms.MenuItem
Friend WithEvents MnuSeperator As System.Windows.Forms.MenuItem
Friend WithEvents Fox As System.Windows.Forms.PictureBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(FrmParent))
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MnuFile = New System.Windows.Forms.MenuItem
Me.Mnuarrested = New System.Windows.Forms.MenuItem
Me.MnuSimpson = New System.Windows.Forms.MenuItem
Me.Mnu24 = New System.Windows.Forms.MenuItem
Me.MnuSeperator = New System.Windows.Forms.MenuItem
Me.Mnuexit = New System.Windows.Forms.MenuItem
Me.MnuWeb = New System.Windows.Forms.MenuItem
Me.MnuVideo = New System.Windows.Forms.MenuItem
Me.Fox = New System.Windows.Forms.PictureBox
Me.SuspendLayout()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MnuFile, Me.MnuWeb, Me.MnuVideo})
'
'MnuFile
'
Me.MnuFile.Index = 0
Me.MnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.Mnuarrested, Me.MnuSimpson, Me.Mnu24, Me.MnuSeperator, Me.Mnuexit})
Me.MnuFile.Text = "File"
'
'Mnuarrested
'
Me.Mnuarrested.Index = 0
Me.Mnuarrested.Text = "Arrested Development"
'
'MnuSimpson
'
Me.MnuSimpson.Index = 1
Me.MnuSimpson.Text = "Simpsons"
'
'Mnu24
'
Me.Mnu24.Index = 2
Me.Mnu24.Text = "24"
'
'MnuSeperator
'
Me.MnuSeperator.Index = 3
Me.MnuSeperator.Text = "-"
'
'Mnuexit
'
Me.Mnuexit.Index = 4
Me.Mnuexit.Text = "Exit"
'
'MnuWeb
'
Me.MnuWeb.Index = 1
Me.MnuWeb.Text = "Web Page"
'
'MnuVideo
'
Me.MnuVideo.Index = 2
Me.MnuVideo.Text = "Videos"
'
'Fox
'
Me.Fox.BackgroundImage = CType(resources.GetObject("Fox.BackgroundImage"), System.Drawing.Image)
Me.Fox.Location = New System.Drawing.Point(8, 0)
Me.Fox.Name = "Fox"
Me.Fox.Size = New System.Drawing.Size(672, 544)
Me.Fox.TabIndex = 0
Me.Fox.TabStop = False
'
'FrmParent
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(712, 521)
Me.Controls.Add(Me.Fox)
Me.IsMdiContainer = True
Me.Menu = Me.MainMenu1
Me.Name = "FrmParent"
Me.Text = "Main Menu"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Fox.Click
End Sub
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Mnuexit.Click
Close()
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Mnuarrested.Click
Dim F1 As New frmchildone
F1.Show()
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuFile.Click
End Sub
Private Sub Mnu24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Mnu24.Click
Dim F2 As New frm24
F2.Show()
End Sub
Private Sub MnuSimpsons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuSimpson.Click
Dim F3 As New frmsimpsons
F3.Show()
End Sub
Private Sub Mnuweb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuWeb.Click
Dim F4 As New frmWebpage
F4.Show()
End Sub
Private Const SND_FILENAME = &H20000
Private Declare Function PlayS Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub form_load()
PlayS("C:\Documents and Settings\USER\Desktop\im_jack_bauer.wav")
End Sub
Private Sub playS(ByVal filename As String)
PlaySound Filename , ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
Private Sub playSound(ByVal filename As String)
PlayS filename, ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
End Class
Thanks
gob_smacked0
Advertisement