1 / 10

The SystemSounds Class

The SystemSounds Class. Includes five properties for making Windows operating system sounds: Asterisk Beep Exclamation Hand Question The Play() method is used to make the sound: SystemSounds.Beep.Play() Applications require the Imports System.Media statement. Playing Sound Files.

scout
Download Presentation

The SystemSounds Class

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The SystemSounds Class • Includes five properties for making Windows operating system sounds:Asterisk Beep Exclamation Hand Question • The Play() method is used to make the sound:SystemSounds.Beep.Play() • Applications require the Imports System.Media statement. Visual Basic - Chapter 10

  2. Playing Sound Files • Visual Basic applications can play Windows WAV audio files. • My.Computer.Audio object includes the Play() and Stop() methods for working with WAV files. • Audio files must be added to the Resources folder for an application to access them. • To add resource: Select menu Project | application Properties; select Resources tab, then Add Resource; browse to audio file • Reference to My.Resources. will then show file • Example playing audio in background: My.Computer.Audio.Play(My.Resources.Bird,AudioPlayMode.Background) Visual Basic - Chapter 10

  3. The Timer Control • Located in Components folder in Toolbox • Properties include: • (Name) should begin with tmr. • Interval is the amount of time that passes before the Tick event procedure executes. • Enabled allows a Tick event to occur at the end of each interval. • Methods include Start() and Stop(). Visual Basic - Chapter 10

  4. Demo: Timer Use a Timer object to alternate the color of a form between red and blue. Experiment with varying Interval values to slow down or speed up the alternating colors. Visual Basic - Chapter 10

  5. Demo: Timer Code for Timer application. Private Sub tmrTimer_Tick() If Me.BackColor = Color.Red Then Me.BackColor = Color.Blue Else Me.BackColor = Color.Red End If End Sub Private Sub Form1_Load() Me.BackColor = Color.Red End Sub Private Sub cmdQuit_Click() Application.Exit() End Sub Experiment with varying Interval values to slow down or speed up the alternating colors. Visual Basic - Chapter 10

  6. Simple Animation • Timers are used to create simple animations • Multiple images are placed on the form, each on top of the others (same size, same place, but with different “phases” in the image) • At any given time, one image is Visible, the others are not • Each time the Timer fires, the visible image changes, rotating through the “phases” • Similar to flipping the corners of the pages in a minibook with “moving images” in the corner Visual Basic - Chapter 10

  7. Simple Animation - Wink • In Paint, create a Smiley face (be sure to crop tight around the face) -> smiley.bmp [open smiley.wmf] • Copy it and erase part of right eye -> smiley2.bmp • Create VB Form with 2 picture boxes overlaid on each other, with smiley visible, smiley2 not visible • Add a timer with Tick event that reverses which image is visible Visual Basic - Chapter 10

  8. Exercise 10-12: TurtleRun Simulate a turtle running by cycling through 3 graphics of a turtle in various stages of walking. Set the timer Interval property to different values in the speed buttons. Visual Basic - Chapter 10

  9. Exercise 10-12: TurtleRun - Code Partial code for TurtleRun is shown below: Option Explicit Private intCycle As Integer Private Sub Form1_Load() intCycle = 1 Me.picTurtle1.Visible = True Me.picTurtle2.Visible = False Me.picTurtle3.Visible = False End Sub Private Sub tmrTurtle_Tick() If intCycle = 1 Then Me.picTurtle1.Visible = True Me.picTurtle2.Visible = False Me.picTurtle3.Visible = False intCycle = 2 ElseIf intCycle = 2 Then Me.picTurtle1.Visible = False Me.picTurtle2.Visible = True Me.picTurtle3.Visible = False intCycle = 3 ElseIf intCycle = 3 Then Me.picTurtle1.Visible = False Me.picTurtle2.Visible = False Me.picTurtle3.Visible = True intCycle = 1 End If End Sub Visual Basic - Chapter 10

  10. Exercise 10-15: Bird Flying Simulate a bird flying by cycling through flying graphics. Visual Basic - Chapter 10

More Related