Click here to Skip to main content
13,348,874 members (77,036 online)
Click here to Skip to main content
Add your own
alternative version


41 bookmarked
Posted 25 Dec 2008

Multiplication Table Practice Tool

, 25 Dec 2008
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.


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.


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
        End With
    End If

End Sub

Private Sub StopBackgroundMusic()


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

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:


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.


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


About the Author

James Ritchie Carroll
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

SuggestionWhy use an embedded Windows Media system? Pin
Member 101318193-Jul-13 4:44
memberMember 101318193-Jul-13 4:44 
QuestionImprovements ? Pin
scalpa9825-Nov-10 9:20
memberscalpa9825-Nov-10 9:20 
Questionm_practiceSetIndex = -1 Pin
scalpa9820-Nov-10 9:31
memberscalpa9820-Nov-10 9:31 
AnswerRe: m_practiceSetIndex = -1 Pin
James Ritchie Carroll22-Nov-10 3:54
memberJames Ritchie Carroll22-Nov-10 3:54 
GeneralRe: m_practiceSetIndex = -1 Pin
scalpa9823-Nov-10 9:46
memberscalpa9823-Nov-10 9:46 
GeneralRe: m_practiceSetIndex = -1 Pin
James Ritchie Carroll23-Nov-10 9:56
memberJames 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. Pin
bobrindner3-Dec-09 19:54
memberbobrindner3-Dec-09 19:54 
GeneralRe: My students absolutely love the interface. I work with many older student who do not know the multiplication tables. Pin
James Ritchie Carroll14-Jul-10 9:56
memberJames Ritchie Carroll14-Jul-10 9:56 
GeneralFantastic Pin
infinitebuzz29-Dec-08 17:30
memberinfinitebuzz29-Dec-08 17:30 
GeneralGreat! Pin
King_kLAx26-Dec-08 1:56
memberKing_kLAx26-Dec-08 1:56 

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.

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