Click here to Skip to main content
Click here to Skip to main content

Multiplication Table Practice Tool

, 25 Dec 2008 BSD
Rate this:
Please Sign up or sign in to vote.
A kid friendly program for practicing multiplication tables; a good example for embedding the Windows Media Player control in an application.

Introduction

I have two school age children, both learning and/or practicing their multiplication tables. I wrote this program to help them practice their multiplication tables in a fun way and focus on specific tables as needed. To help it be more fun, I wanted it to play music in the background and provide good A/V feedback based on correct or incorrect responses. I found lots of applications out there that does this sort of thing, but usually, they were something to buy or web based applications. I wanted something that was customizable, and could run locally without worrying with a browser or an Internet connection. I also wanted an application that could run easily from the numeric keypad while practicing – these were especially important since the target audience was younger children.

Background

I had never attempted to put background music in an application, so I tinkered with several options. In the end, I went with embedding a Windows Media Player control into the application (see Embedding Windows Media Player below to see how). It was flexible, and natively supported a large variety of musical formats.

Using the Windows Media Player Control

The actual documentation of the Windows Media Player Control can be found on MSDN. I’ll focus on the properties I needed in this simple application.

The media player control has a settings property that allows access to several playing attributes (e.g., auto-start, play count, and volume). The following code shows how these were applied:

' We just use Windows Media Player to play background music
With MediaPlayer
    With .settings
        .autoStart = False
        .playCount = Integer.MaxValue
        .volume = 10
    End With

    .URL = Application.StartupPath & "\Audio\BackgroundJam.wma"
End With

Note that I simply set the play count to the maximum integer value to, in effect, create an endless playing loop for the music. Volume was set to 10, nice and low for background music - but not too distracting.

To play and pause the music, you access the Ctlcontrols property as follows:

Private Sub StartBackgroundMusic()

    If m_backgroundMusicEnabled Then
        With MediaPlayer.Ctlcontrols
            .currentPosition = 0
            .play()
        End With
    End If

End Sub

Private Sub StopBackgroundMusic()

    MediaPlayer.Ctlcontrols.stop()

End Sub

Embedding the Windows Media Player

To embed the Windows Media Player control into your own application, you must click “Choose Items” from the Visual Studio toolbox (visible when a form is in design mode), then select the “COM Components” tab – be patient, this may take a while to load. If you have Windows Media Player installed on your system, there should be a COM component labeled “Windows Media Player” with a path such as C:\Windows\system32\wmp.dll; check this item, and click OK. If all you want is music in your application (i.e., not video), make sure and set the Visible property of the control to False.

Points of Interest

There is a class provided (ConfigurationSettings.vb) in the source code that simplifies the usage of saving and retrieving settings from a local configuration file. It automatically casts settings to and from Boolean and Integer values; here is an example of its usage:

Private Sub PracticeTool_FormClosing(ByVal sender As Object, ByVal e As _
        System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

    m_countDownTimer.Enabled = False
    BooleanSetting("RandomTestOrder") = m_randomTestOrder
    BooleanSetting("IncludeZeroInRange") = m_includeZeroInRange
    BooleanSetting("AudioFeedbackEnabled") = m_audioFeedbackEnabled
    BooleanSetting("BackgroundMusicEnabled") = m_backgroundMusicEnabled
    BooleanSetting("BackgroundMusicAlwaysOn") = m_backgroundMusicAlwaysOn
    IntegerSetting("CorrectAnswerDelay") = m_correctAnswerDelay
    IntegerSetting("IncorrectAnswerDelay") = m_incorrectAnswerDelay
    IntegerSetting("CountDownTime") = m_countDownTime
    BooleanSetting("WrongAnswerOnTimeout") = m_wrongAnswerOnTimeout
    Setting("PracticeNumbers") = Numbers.Text
    Setting("PracticeRange") = Range.Text
    Setting("ChildsName") = m_childsName
    SaveSettings()

End Sub

Generally, this application should be a good example for anyone getting started with VB.NET.

Using the Application

Assuming you actually got to this page to simply use this program for your own child, no worries – usage should be simple enough. All you need to do is just deploy the binaries into their own folder and run the executable. Watch for tool-tips for help, and adjust the options as needed. Again, the application uses the Windows Media Player control internally, so having Windows Media Player installed is a prerequisite. There are several options to tailor the usage to an individual child’s needs:

Multiplication_Table_Practice_Tool_Options.JPG

Additionally, the audio used by the program can be easily changed in the "Audio" folder to fit your child's interests a little better - this includes a "background jam" to keep things interesting. Simply override the existing files with the sound files of your preference, just make sure and use the same file names.

License

This article, along with any associated source code and files, is licensed under The BSD License

Share

About the Author

James Ritchie Carroll
Architect
United States United States
No Biography provided

Comments and Discussions

 
SuggestionWhy use an embedded Windows Media system? PinmemberMember 101318193-Jul-13 4:44 
QuestionImprovements ? Pinmemberscalpa9825-Nov-10 9:20 
Questionm_practiceSetIndex = -1 Pinmemberscalpa9820-Nov-10 9:31 
AnswerRe: m_practiceSetIndex = -1 PinmemberJames Ritchie Carroll22-Nov-10 3:54 
GeneralRe: m_practiceSetIndex = -1 Pinmemberscalpa9823-Nov-10 9:46 
GeneralRe: m_practiceSetIndex = -1 PinmemberJames Ritchie Carroll23-Nov-10 9:56 
GeneralMy students absolutely love the interface. I work with many older student who do not know the multiplication tables. Pinmemberbobrindner3-Dec-09 19:54 
GeneralRe: My students absolutely love the interface. I work with many older student who do not know the multiplication tables. PinmemberJames Ritchie Carroll14-Jul-10 9:56 
GeneralFantastic Pinmemberinfinitebuzz29-Dec-08 17:30 
GeneralGreat! PinmemberKing_kLAx26-Dec-08 1:56 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 25 Dec 2008
Article Copyright 2008 by James Ritchie Carroll
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid