VB Tutor VB2022 VB2019 VB6 VB Sample Code About Us
Kid Math - Educational Arithmetic Game

Kid Math - Educational Arithmetic Game

Interactive math learning tool for children with visual feedback


Kid Math is a fun educational game designed to help children practice their arithmetic skills. This interactive tool allows children to solve addition problems at three different difficulty levels and provides immediate feedback on their answers.

Originally developed in Visual Basic 6, this application demonstrates how programming can be used to create engaging educational tools. The application tracks performance metrics including total questions attempted, correct answers, and overall score percentage.

Interactive Demo

Level 1 (1-10)
Level 2 (1-100)
Level 3 (1-1000)
5 + 3 =
Questions
0
Correct
0
Score
0%

Code Examples

' Kid Math - VB6 Version
Dim num1 As Integer
Dim num2 As Integer
Dim intNumber As Integer
Dim n As Integer

Private Sub score()
    intNumber = intNumber + 1
End Sub

Private Sub begin()
    intNumber = 0
    Image1.Visible = False
    Image2.Visible = False
    Label6.Visible = False
    Label5.Visible = False
    Text3.Text = ""
    
    If Option1.Value = "true" Then
        n = 10
    ElseIf Option2.Value = "true" Then
        n = 100
    ElseIf Option3.Value = "true" Then
        n = 1000
    End If
    
    num1 = Int(Rnd * n)
    num2 = Int(Rnd * n)
    Text1.Text = num1
    Text2.Text = num2
    Text3.SetFocus
End Sub

Private Sub Form_Load()
    Image1.Visible = False
    Image2.Visible = False
    Label6.Visible = False
    Label5.Visible = False
    Randomize
End Sub

Private Sub Start_Click()
    begin
End Sub

Private Sub text3_keyDown(keyCode As Integer, shift As Integer)
    If keyCode = vbKeyNext Or keyCode = vbKeyDown Then
        begin
    End If
End Sub

Private Sub text3_keypress(keyAscii As Integer)
    If (keyAscii = 13) And Val(Text3.Text) = Val(Text1.Text) + Val(Text2.Text) Then
        Image1.Visible = True
        Image2.Visible = False
        Label5.Visible = True
        Label6.Visible = False
        score
        total.Caption = Str$(intNumber)
    ElseIf (keyAscii = 13) And Val(Text3.Text) <> Val(Text1.Text) + Val(Text2.Text) Then
        Image1.Visible = False
        Image2.Visible = True
        Label5.Visible = False
        Label6.Visible = True
        Text3.Text = ""
    End If
End Sub

Private Sub Next_Click()
    Image1.Visible = False
    Image2.Visible = False
    Label6.Visible = False
    Label5.Visible = False
    
    If Option1.Value = "true" Then
        n = 10
    ElseIf Option2.Value = "true" Then
        n = 100
    ElseIf Option3.Value = "true" Then
        n = 1000
    End If
    
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""

    num1 = Int(Rnd * n)
    num2 = Int(Rnd * n)
    Text1.Text = num1
    Text2.Text = num2
    Text3.SetFocus
End Sub

Private Sub OK_Click()
    If Val(Text3.Text) = Val(Text1.Text) + Val(Text2.Text) Then
        Image1.Visible = True
        Image2.Visible = False
        Label5.Visible = True
        Label6.Visible = False
        score
        total.Caption = Str$(intNumber)
    Else
        Image1.Visible = False
        Image2.Visible = True
        Label5.Visible = False
        Label6.Visible = True
        Text3.Text = ""
    End If
End Sub

Private Sub Option1_Click()
    n = 10
End Sub

Private Sub Option2_Click()
    n = 100
End Sub

Private Sub Option3_Click()
    n = 1000
End Sub
' Kid Math - VB.NET Version
Public Class KidMathForm
    Private num1 As Integer
    Private num2 As Integer
    Private totalQuestions As Integer = 0
    Private correctAnswers As Integer = 0
    Private currentLevel As Integer = 10
    
    Private Sub StartButton_Click(sender As Object, e As EventArgs) Handles StartButton.Click
        ResetGame()
        GenerateNewProblem()
    End Sub
    
    Private Sub CheckButton_Click(sender As Object, e As EventArgs) Handles CheckButton.Click
        CheckAnswer()
    End Sub
    
    Private Sub NextButton_Click(sender As Object, e As EventArgs) Handles NextButton.Click
        GenerateNewProblem()
        FeedbackLabel.Visible = False
        AnswerTextBox.Text = ""
    End Sub
    
    Private Sub Level1Radio_CheckedChanged(sender As Object, e As EventArgs) Handles Level1Radio.CheckedChanged
        If Level1Radio.Checked Then
            currentLevel = 10
            GenerateNewProblem()
        End If
    End Sub
    
    Private Sub Level2Radio_CheckedChanged(sender As Object, e As EventArgs) Handles Level2Radio.CheckedChanged
        If Level2Radio.Checked Then
            currentLevel = 100
            GenerateNewProblem()
        End If
    End Sub
    
    Private Sub Level3Radio_CheckedChanged(sender As Object, e As EventArgs) Handles Level3Radio.CheckedChanged
        If Level3Radio.Checked Then
            currentLevel = 1000
            GenerateNewProblem()
        End If
    End Sub
    
    Private Sub AnswerTextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles AnswerTextBox.KeyPress
        If e.KeyChar = ChrW(Keys.Enter) Then
            CheckAnswer()
            e.Handled = True
        End If
    End Sub
    
    Private Sub ResetGame()
        totalQuestions = 0
        correctAnswers = 0
        UpdateStats()
        FeedbackLabel.Visible = False
        AnswerTextBox.Text = ""
    End Sub
    
    Private Sub GenerateNewProblem()
        Dim rnd As New Random()
        num1 = rnd.Next(1, currentLevel)
        num2 = rnd.Next(1, currentLevel)
        Number1Label.Text = num1.ToString()
        Number2Label.Text = num2.ToString()
        AnswerTextBox.Text = ""
        AnswerTextBox.Focus()
    End Sub
    
    Private Sub CheckAnswer()
        Dim userAnswer As Integer
        If Integer.TryParse(AnswerTextBox.Text, userAnswer) Then
            totalQuestions += 1
            
            If userAnswer = num1 + num2 Then
                correctAnswers += 1
                FeedbackLabel.Text = "Correct! 😊"
                FeedbackLabel.ForeColor = Color.Green
            Else
                FeedbackLabel.Text = "Try again! 😢"
                FeedbackLabel.ForeColor = Color.Red
            End If
            
            FeedbackLabel.Visible = True
            UpdateStats()
        Else
            MessageBox.Show("Please enter a valid number", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub
    
    Private Sub UpdateStats()
        TotalQuestionsLabel.Text = totalQuestions.ToString()
        CorrectAnswersLabel.Text = correctAnswers.ToString()
        
        Dim scorePercentage As Integer = 0
        If totalQuestions > 0 Then
            scorePercentage = CInt((correctAnswers / totalQuestions) * 100)
        End If
        ScoreLabel.Text = scorePercentage.ToString() & "%"
    End Sub
End Class

Educational Value

Cognitive Development

Improves arithmetic skills and mental calculation abilities

Engaging Learning

Game-like interface makes learning math enjoyable

Progress Tracking

Visual feedback helps children understand their progress

Adaptive Difficulty

Three levels accommodate different skill levels

Key Programming Concepts

This application demonstrates several fundamental programming concepts:

Tip: The transition from VB6 to VB.NET demonstrates how modern programming practices improve code organization and maintainability.