VERSION 5.00
Begin VB.Form frmMadMinute 
   BackColor       =   &H00FFFF00&
   Caption         =   "The Mad Minute!"
   ClientHeight    =   6465
   ClientLeft      =   2715
   ClientTop       =   2805
   ClientWidth     =   9870
   LinkTopic       =   "Form1"
   ScaleHeight     =   6465
   ScaleWidth      =   9870
   Begin VB.CommandButton cmdBackTo2 
      Caption         =   "Back to Step 2"
      Enabled         =   0   'False
      Height          =   375
      Left            =   7200
      TabIndex        =   25
      Top             =   3600
      Width           =   1215
   End
   Begin VB.Timer tmrTime 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   360
      Top             =   360
   End
   Begin VB.Frame frmGround 
      BackColor       =   &H00FFFF00&
      Enabled         =   0   'False
      Height          =   1815
      Left            =   960
      TabIndex        =   12
      Top             =   3960
      Width           =   7935
      Begin VB.CommandButton cmdStop 
         Caption         =   "Stop!"
         Height          =   375
         Left            =   3960
         TabIndex        =   27
         Top             =   1320
         Width           =   1215
      End
      Begin VB.TextBox txtIncorrect 
         Enabled         =   0   'False
         Height          =   375
         Left            =   5400
         TabIndex        =   20
         Top             =   960
         Width           =   735
      End
      Begin VB.TextBox txtCorrect 
         Enabled         =   0   'False
         Height          =   375
         Left            =   5400
         TabIndex        =   19
         Top             =   480
         Width           =   735
      End
      Begin VB.TextBox txtAnswer 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   2880
         TabIndex        =   15
         Top             =   720
         Width           =   855
      End
      Begin VB.TextBox txtEquation 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   360
         TabIndex        =   13
         Top             =   720
         Width           =   2175
      End
      Begin VB.Label lblCorrectAns 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFF00&
         Height          =   255
         Left            =   480
         TabIndex        =   26
         Top             =   1440
         Width           =   3135
      End
      Begin VB.Label lblIncorrect 
         BackColor       =   &H00FFFF00&
         Caption         =   "answered incorrectly"
         Height          =   255
         Left            =   6240
         TabIndex        =   22
         Top             =   960
         Width           =   1455
      End
      Begin VB.Label lblCorrect 
         BackColor       =   &H00FFFF00&
         Caption         =   "answered correctly"
         Height          =   255
         Left            =   6240
         TabIndex        =   21
         Top             =   480
         Width           =   1455
      End
      Begin VB.Label lblTime 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFF00&
         Caption         =   "60"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   24
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   4080
         TabIndex        =   18
         Top             =   720
         Width           =   975
      End
      Begin VB.Label lblTimeR 
         BackColor       =   &H00FFFF00&
         Caption         =   "Time Remaining:"
         Height          =   255
         Left            =   3960
         TabIndex        =   17
         Top             =   480
         Width           =   1335
      End
      Begin VB.Label lblStep4 
         BackColor       =   &H00FFFF00&
         Caption         =   "Enter the answer and press the Enter Key"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   16
         Top             =   360
         Width           =   4335
      End
      Begin VB.Label lblEquals 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFF00&
         Caption         =   "="
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2520
         TabIndex        =   14
         Top             =   840
         Width           =   375
      End
   End
   Begin VB.CommandButton cmdGo 
      Caption         =   "Go!"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   6240
      TabIndex        =   11
      Top             =   3600
      Width           =   855
   End
   Begin VB.Frame frmStep2 
      BackColor       =   &H00FFFF00&
      Caption         =   "Step 2. Choose numbers between 1 and 12"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2415
      Left            =   4440
      TabIndex        =   5
      Top             =   1080
      Width           =   4455
      Begin VB.CommandButton cmdBackTo1 
         Caption         =   "Back to Step 1"
         Height          =   375
         Left            =   480
         TabIndex        =   24
         Top             =   1560
         Width           =   1335
      End
      Begin VB.ComboBox cmbLow 
         Height          =   315
         Left            =   2880
         TabIndex        =   9
         Text            =   "0"
         Top             =   600
         Width           =   735
      End
      Begin VB.ComboBox cmbHigh 
         Height          =   315
         Left            =   2880
         TabIndex        =   7
         Text            =   "0"
         Top             =   1080
         Width           =   735
      End
      Begin VB.Label lblLowNumber 
         BackColor       =   &H00FFFF00&
         Caption         =   "Choose low number:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   8
         Top             =   600
         Width           =   2655
      End
      Begin VB.Label lblHighNumber 
         BackColor       =   &H00FFFF00&
         Caption         =   "Choose high number:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   6
         Top             =   1080
         Width           =   2655
      End
   End
   Begin VB.Frame frmStep1 
      BackColor       =   &H00FFFF00&
      Caption         =   "Step 1. Choose an operation"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2415
      Left            =   960
      TabIndex        =   3
      Top             =   1080
      Width           =   3375
      Begin VB.ListBox lstSelectOp 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1560
         ItemData        =   "frmMadMinute.frx":0000
         Left            =   360
         List            =   "frmMadMinute.frx":0013
         TabIndex        =   4
         Top             =   480
         Width           =   2655
      End
   End
   Begin VB.Label lblCredit 
      BackColor       =   &H00FFFF00&
      Caption         =   "Created By: Nick Miller  Mar. 2006"
      Height          =   255
      Left            =   6480
      TabIndex        =   23
      Top             =   5880
      Width           =   2415
   End
   Begin VB.Label lblStep3 
      BackColor       =   &H00FFFF00&
      Caption         =   "Step 3. When you are ready click"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1920
      TabIndex        =   10
      Top             =   3600
      Width           =   4215
   End
   Begin VB.Label lblTitle3 
      BackColor       =   &H00FFFF00&
      Caption         =   "Minute"
      BeginProperty Font 
         Name            =   "Goudy Stout"
         Size            =   24
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   735
      Left            =   5160
      TabIndex        =   2
      Top             =   240
      Width           =   3735
   End
   Begin VB.Label lblTitle2 
      BackColor       =   &H00FFFF00&
      Caption         =   "Mad"
      BeginProperty Font 
         Name            =   "Goudy Stout"
         Size            =   24
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   735
      Left            =   3120
      TabIndex        =   1
      Top             =   240
      Width           =   2055
   End
   Begin VB.Label lblTitle1 
      BackColor       =   &H00FFFF00&
      Caption         =   "The"
      BeginProperty Font 
         Name            =   "Goudy Stout"
         Size            =   24
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000C000&
      Height          =   615
      Left            =   960
      TabIndex        =   0
      Top             =   240
      Width           =   1935
   End
End
Attribute VB_Name = "frmMadMinute"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
    Dim blnSubtract As Boolean, blnAdd As Boolean, blnMult As Boolean, blnDiv As Boolean, blnRandom As Boolean
    Dim blnCombo1 As Boolean, blnCombo2 As Boolean
    Dim intTime As Integer
    Dim intLow As Integer, intHigh As Integer
    Dim intCorrect As Integer, intIncorrect As Integer, intEqCount
    'Function GetAddition variables
    Dim intFirst As Integer, intSecond As Integer
    'Function GetSubtraction variables
    Dim MainNum As Integer, LowNum As Integer
    Dim LastMain As Integer

Public Function Rand(ByVal low As Long, ByVal high As Long) As Long
    Rand = low + Rnd() * (high - low)
End Function

Public Function GetSubtraction(ByVal low As Integer, ByVal high As Integer) As String
    intEqCount = intEqCount + 1
    Do
        MainNum = Rand(low, high)
    Loop Until MainNum <> LastMain
    LastMain = MainNum
    Do
        DoEvents
        LowNum = Rand(low, high)
    Loop Until LowNum < MainNum
    GetSubtraction = MainNum & " - " & LowNum
End Function

Public Function GetAddition(ByVal low As Integer, ByVal high As Integer) As String
    intEqCount = intEqCount + 1
    intFirst = Rand(low, high)
    intSecond = Rand(low, high)
    If blnAdd Then
        GetAddition = intFirst & " " & "+" & " " & intSecond
    End If
End Function

Private Sub cmbHigh_Click()
    blnCombo1 = True
    If blnCombo1 And cmbLow.Text = "0" Then
        cmdGo.Enabled = True
        cmdBackTo2.Enabled = True
        frmStep2.Enabled = False
        blnCombo2 = False
        blnCombo1 = False
    ElseIf blnCombo1 And blnCombo2 Then
        cmdGo.Enabled = True
        cmdBackTo2.Enabled = True
        frmStep2.Enabled = False
        blnCombo2 = False
        blnCombo1 = False
    End If
End Sub

Private Sub cmbLow_Click()
    blnCombo2 = True
    If blnCombo1 And blnCombo2 Then
        cmdGo.Enabled = True
        cmdBackTo2.Enabled = True
        frmStep2.Enabled = False
        blnCombo2 = False
        blnCombo1 = False
    End If
End Sub

Private Sub cmdBackTo1_Click()
    frmStep1.Enabled = True
    frmStep2.Enabled = False
    cmdGo.Enabled = False
End Sub

Private Sub cmdBackTo2_Click()
    frmStep2.Enabled = True
    cmdGo.Enabled = False
    cmdBackTo2.Enabled = False
End Sub

Private Sub cmdGo_Click()
    frmGround.Enabled = True
    intLow = cmbLow.Text
    intHigh = cmbHigh.Text
    If blnAdd Then
        txtEquation.Text = GetAddition(intLow, intHigh)
    ElseIf blnSubtract Then
        txtEquation.Text = GetSubtraction(intLow, intHigh)
    End If
    tmrTime.Enabled = True
    cmdBackTo2.Enabled = False
    txtAnswer.SetFocus
End Sub

Private Sub Command1_Click()
    intLow = cmbLow.Text
    intHigh = cmbHigh.Text
    MsgBox GetSubtraction(intLow, intHigh)
End Sub

Private Sub cmdStop_Click()
    tmrTime.Enabled = False
    intTime = 60
End Sub

Private Sub Form_Load()
    Randomize
    Debug.Print " " & vbCrLf & " --New Program Start-- "
    Dim i As Integer
        For i = 0 To 12
            cmbHigh.AddItem i
            cmbLow.AddItem i
        Next i
    intTime = 60
End Sub

Private Sub lstSelectOp_Click()
    Select Case lstSelectOp.ListIndex
        Case 0
            blnAdd = True
        Case 1
            blnSubtract = True
        Case 2
            blnMult = True
        Case 3
            blnDiv = True
        Case 4
            blnRandom = True
    End Select
    frmStep2.Enabled = True
    frmStep1.Enabled = False
    cmdGo.Enabled = False
End Sub

Private Sub tmrTime_Timer()
    intTime = intTime - 1
    If intTime = 10 Then
        lblTime.ForeColor = vbRed
    ElseIf intTime = 0 Then
        Dim sTempMsg As String
        tmrTime.Enabled = False
        lblTime.Caption = intTime
        sTempMsg = "Time's Up!" & vbCrLf & "Your Results:" & vbCrLf & "       " & _
        intCorrect & "/" & intEqCount - 1 & " Correct" & vbCrLf & "       " & _
        intIncorrect & "/" & intEqCount - 1 & " Incorrect"
        MsgBox sTempMsg, vbInformation
        Exit Sub
    End If
    lblTime.Caption = intTime
End Sub

Private Sub txtAnswer_KeyPress(KeyAscii As Integer)
    Dim intCheck As Integer, sTempMsg As String
    If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 And KeyAscii <> 13 And KeyAscii <> 8 Then
        KeyAscii = 0
        Exit Sub
    ElseIf KeyAscii = 13 Then
        If txtAnswer.Text = "" Then Exit Sub
            If Len(txtAnswer.Text) > 4 Then
                txtAnswer.Text = ""
                txtAnswer.SetFocus
                Exit Sub
            End If
            intCheck = txtAnswer.Text
            If blnAdd Then
                If intFirst + intSecond = intCheck Then
                    intCorrect = intCorrect + 1
                    txtCorrect.Text = intCorrect
                    txtAnswer.Text = ""
                    txtAnswer.SetFocus
                    txtEquation.Text = GetAddition(intLow, intHigh)
                ElseIf intFirst + intSecond <> intCheck Then
                    lblCorrectAns.Caption = intFirst & " + " & intSecond & " = " & intFirst + intSecond
                    intIncorrect = intIncorrect + 1
                    txtIncorrect.Text = intIncorrect
                    txtAnswer.Text = ""
                    txtAnswer.SetFocus
                    txtEquation.Text = GetAddition(intLow, intHigh)
                End If
            ElseIf blnSubtract Then
                Debug.Print MainNum & " " & LowNum & " " & intCheck
                If MainNum - LowNum = intCheck Then
                    intCorrect = intCorrect + 1
                    txtCorrect.Text = intCorrect
                    txtAnswer.Text = ""
                    txtAnswer.SetFocus
                    txtEquation.Text = GetSubtraction(intLow, intHigh)
                ElseIf MainNum - LowNum <> intCheck Then
                    lblCorrectAns.Caption = MainNum & " - " & LowNum & " = " & MainNum - LowNum
                    intIncorrect = intIncorrect + 1
                    txtIncorrect.Text = intIncorrect
                    txtAnswer.Text = ""
                    txtAnswer.SetFocus
                    txtEquation.Text = GetSubtraction(intLow, intHigh)
                End If
            End If
    End If
End Sub
