VERSION 5.00
Begin VB.Form frmMath 
   Caption         =   "Math Practice"
   ClientHeight    =   5100
   ClientLeft      =   1536
   ClientTop       =   2268
   ClientWidth     =   8184
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   5100
   ScaleWidth      =   8184
   Begin VB.CheckBox chkDisplay 
      Caption         =   "&Display summary information"
      Height          =   252
      Left            =   5400
      TabIndex        =   6
      Top             =   2400
      Width           =   2412
   End
   Begin VB.Frame Frame3 
      Caption         =   "Operations"
      Height          =   1812
      Left            =   2880
      TabIndex        =   17
      Top             =   2280
      Width           =   2172
      Begin VB.OptionButton optSub 
         Caption         =   "&Subtraction"
         Height          =   372
         Left            =   360
         TabIndex        =   5
         Top             =   960
         Width           =   1212
      End
      Begin VB.OptionButton optAdd 
         Caption         =   "&Addition"
         Height          =   495
         Left            =   360
         TabIndex        =   4
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Levels"
      Height          =   1812
      Left            =   360
      TabIndex        =   16
      Top             =   2280
      Width           =   2292
      Begin VB.OptionButton optLevel1 
         Caption         =   "Level &1   (1-10)"
         Height          =   495
         Left            =   240
         TabIndex        =   2
         Top             =   360
         Width           =   1695
      End
      Begin VB.OptionButton optLevel2 
         Caption         =   "Level &2   (10-100)"
         Height          =   495
         Left            =   240
         TabIndex        =   3
         Top             =   960
         Width           =   1695
      End
   End
   Begin VB.Frame fraInfo 
      Height          =   1215
      Left            =   5400
      TabIndex        =   11
      Top             =   2760
      Visible         =   0   'False
      Width           =   2415
      Begin VB.Label lblIncorrect 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1440
         TabIndex        =   15
         Top             =   480
         Width           =   735
      End
      Begin VB.Label lblCorrect 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   120
         TabIndex        =   14
         Top             =   480
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "Correct:"
         Height          =   195
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   630
      End
      Begin VB.Label Label4 
         Caption         =   "Incorrect:"
         Height          =   240
         Left            =   1440
         TabIndex        =   12
         Top             =   240
         Width           =   750
      End
   End
   Begin VB.Frame Frame1 
      Height          =   1935
      Left            =   360
      TabIndex        =   8
      Top             =   240
      Width           =   7455
      Begin VB.CommandButton cmdVerify 
         Caption         =   "&Verify Answer"
         Default         =   -1  'True
         Height          =   495
         Left            =   5640
         TabIndex        =   1
         Top             =   840
         Width           =   1215
      End
      Begin VB.TextBox txtAnswer 
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.8
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   3840
         TabIndex        =   0
         Top             =   840
         Width           =   735
      End
      Begin VB.Image imgIcon 
         BorderStyle     =   1  'Fixed Single
         Height          =   492
         Left            =   4800
         Top             =   840
         Width           =   612
      End
      Begin VB.Image imgOperator 
         Height          =   495
         Left            =   1560
         Top             =   840
         Width           =   375
      End
      Begin VB.Label lblNum1 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.8
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   495
         Left            =   600
         TabIndex        =   10
         Top             =   840
         Width           =   735
      End
      Begin VB.Label lblNum2 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.8
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   495
         Left            =   2160
         TabIndex        =   9
         Top             =   840
         Width           =   735
      End
      Begin VB.Image imgEqual 
         Height          =   384
         Left            =   3120
         Picture         =   "frmMain.frx":0000
         Top             =   840
         Width           =   384
      End
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "E&xit"
      Height          =   495
      Left            =   6600
      TabIndex        =   7
      Top             =   4320
      Width           =   1215
   End
   Begin VB.Image imgMinus 
      Height          =   384
      Left            =   1560
      Picture         =   "frmMain.frx":0442
      Top             =   4440
      Visible         =   0   'False
      Width           =   384
   End
   Begin VB.Image imgPlus 
      Height          =   384
      Left            =   960
      Picture         =   "frmMain.frx":0884
      Top             =   4440
      Visible         =   0   'False
      Width           =   384
   End
   Begin VB.Image imgHappy 
      Height          =   384
      Left            =   360
      Picture         =   "frmMain.frx":0CC6
      Top             =   4440
      Visible         =   0   'False
      Width           =   384
   End
End
Attribute VB_Name = "frmMath"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim intNum1 As Integer, intNum2 As Integer


Private Sub chkDisplay_Click()
    If chkDisplay.Value = vbChecked Then
        fraInfo.Visible = True
    Else
        fraInfo.Visible = False
    End If
    
End Sub

Private Sub cmdExit_Click()
    End
End Sub

Private Sub cmdVerify_Click()
    Dim intUserAnswer As Integer, intCorrectAnswer As Integer
    Static intNumCorrect As Integer, intNumIncorrect As Integer
    
    intUserAnswer = Val(txtAnswer.Text)
    
    If optAdd.Value = True Then
        intCorrectAnswer = intNum1 + intNum2
    Else
        intCorrectAnswer = intNum1 - intNum2
    End If
    
    Select Case intUserAnswer
        Case Is = intCorrectAnswer
            imgIcon.Picture = imgHappy.Picture
            intNumCorrect = intNumCorrect + 1
            txtAnswer.Text = ""
            Call RandomNumbers
        Case Else
            imgIcon.Picture = LoadPicture()
            intNumIncorrect = intNumIncorrect + 1
            MsgBox ("Try again.")
            txtAnswer.SelStart = 0
            txtAnswer.SelLength = Len(txtAnswer.Text)
    End Select
    
    txtAnswer.SetFocus
    lblCorrect.Caption = intNumCorrect
    lblIncorrect.Caption = intNumIncorrect
    
End Sub

Private Sub Form_Load()
    frmMath.Top = (Screen.Height - frmMath.Height) / 2
    frmMath.Left = (Screen.Width - frmMath.Width) / 2
    optLevel1.Value = True
    optAdd.Value = True
    
End Sub

Private Sub RandomNumbers()
    Dim intTemp As Integer
    Randomize
    If optLevel1.Value = True Then
        intNum1 = Int((10 - 1 + 1) * Rnd + 1)
        intNum2 = Int((10 - 1 + 1) * Rnd + 1)
    Else
        intNum1 = Int((100 - 10 + 1) * Rnd + 10)
        intNum2 = Int((100 - 10 + 1) * Rnd + 10)
    End If
    
    If optSub.Value = True And intNum2 > intNum1 Then
        intTemp = intNum1
        intNum1 = intNum2
        intNum2 = intTemp
    End If
        
    
    lblNum1.Caption = intNum1
    lblNum2.Caption = intNum2
    
End Sub

Private Sub optAdd_Click()
    Call RandomNumbers
    imgOperator.Picture = imgPlus.Picture
    
End Sub

Private Sub optLevel1_Click()
    Call RandomNumbers
End Sub

Private Sub optLevel2_Click()
    Call RandomNumbers
End Sub

Private Sub optSub_Click()
    Call RandomNumbers
    imgOperator.Picture = imgMinus.Picture
End Sub

Private Sub txtAnswer_GotFocus()
    txtAnswer.SelStart = 0
    txtAnswer.SelLength = Len(txtAnswer.Text)
    
End Sub
