Public Class MathForm Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents ProblemGroupBox As System.Windows.Forms.GroupBox Friend WithEvents AnswerTextBox As System.Windows.Forms.TextBox Friend WithEvents OperationGroupBox As System.Windows.Forms.GroupBox Friend WithEvents AdditionRadioButton As System.Windows.Forms.RadioButton Friend WithEvents IdCorrectLabel As System.Windows.Forms.Label Friend WithEvents IdIncorrectLabel As System.Windows.Forms.Label Friend WithEvents CorrectLabel As System.Windows.Forms.Label Friend WithEvents IncorrectLabel As System.Windows.Forms.Label Friend WithEvents ExitButton As System.Windows.Forms.Button Friend WithEvents SummaryGroupBox As System.Windows.Forms.GroupBox Friend WithEvents PlusPictureBox As System.Windows.Forms.PictureBox Friend WithEvents MinusPictureBox As System.Windows.Forms.PictureBox Friend WithEvents CheckAnswerButton As System.Windows.Forms.Button Friend WithEvents HappyPictureBox As System.Windows.Forms.PictureBox Friend WithEvents NeutralPictureBox As System.Windows.Forms.PictureBox Friend WithEvents Grade2RadioButton As System.Windows.Forms.RadioButton Friend WithEvents GradeGroupBox As System.Windows.Forms.GroupBox Friend WithEvents Grade1RadioButton As System.Windows.Forms.RadioButton Friend WithEvents SubtractionRadioButton As System.Windows.Forms.RadioButton Friend WithEvents SummaryCheckBox As System.Windows.Forms.CheckBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TbxNum1 As System.Windows.Forms.TextBox Friend WithEvents TbxNum2 As System.Windows.Forms.TextBox Friend WithEvents LblSymbol As System.Windows.Forms.Label Friend WithEvents Label1 As System.Windows.Forms.Label Private Sub InitializeComponent() Me.IdCorrectLabel = New System.Windows.Forms.Label Me.SummaryCheckBox = New System.Windows.Forms.CheckBox Me.PlusPictureBox = New System.Windows.Forms.PictureBox Me.OperationGroupBox = New System.Windows.Forms.GroupBox Me.AdditionRadioButton = New System.Windows.Forms.RadioButton Me.SubtractionRadioButton = New System.Windows.Forms.RadioButton Me.AnswerTextBox = New System.Windows.Forms.TextBox Me.SummaryGroupBox = New System.Windows.Forms.GroupBox Me.CorrectLabel = New System.Windows.Forms.Label Me.IdIncorrectLabel = New System.Windows.Forms.Label Me.IncorrectLabel = New System.Windows.Forms.Label Me.ProblemGroupBox = New System.Windows.Forms.GroupBox Me.LblSymbol = New System.Windows.Forms.Label Me.TbxNum2 = New System.Windows.Forms.TextBox Me.TbxNum1 = New System.Windows.Forms.TextBox Me.ExitButton = New System.Windows.Forms.Button Me.CheckAnswerButton = New System.Windows.Forms.Button Me.GradeGroupBox = New System.Windows.Forms.GroupBox Me.Grade1RadioButton = New System.Windows.Forms.RadioButton Me.Grade2RadioButton = New System.Windows.Forms.RadioButton Me.MinusPictureBox = New System.Windows.Forms.PictureBox Me.NeutralPictureBox = New System.Windows.Forms.PictureBox Me.HappyPictureBox = New System.Windows.Forms.PictureBox Me.Label1 = New System.Windows.Forms.Label Me.OperationGroupBox.SuspendLayout() Me.SummaryGroupBox.SuspendLayout() Me.ProblemGroupBox.SuspendLayout() Me.GradeGroupBox.SuspendLayout() Me.SuspendLayout() ' 'IdCorrectLabel ' Me.IdCorrectLabel.AutoSize = True Me.IdCorrectLabel.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.IdCorrectLabel.Location = New System.Drawing.Point(8, 16) Me.IdCorrectLabel.Name = "IdCorrectLabel" Me.IdCorrectLabel.Size = New System.Drawing.Size(59, 19) Me.IdCorrectLabel.TabIndex = 0 Me.IdCorrectLabel.Text = "Correct:" ' 'SummaryCheckBox ' Me.SummaryCheckBox.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.SummaryCheckBox.Location = New System.Drawing.Point(336, 144) Me.SummaryCheckBox.Name = "SummaryCheckBox" Me.SummaryCheckBox.Size = New System.Drawing.Size(152, 32) Me.SummaryCheckBox.TabIndex = 3 Me.SummaryCheckBox.Text = "&Display summary" ' 'PlusPictureBox ' Me.PlusPictureBox.Location = New System.Drawing.Point(24, 272) Me.PlusPictureBox.Name = "PlusPictureBox" Me.PlusPictureBox.Size = New System.Drawing.Size(16, 16) Me.PlusPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize Me.PlusPictureBox.TabIndex = 5 Me.PlusPictureBox.TabStop = False Me.PlusPictureBox.Visible = False ' 'OperationGroupBox ' Me.OperationGroupBox.Controls.Add(Me.AdditionRadioButton) Me.OperationGroupBox.Controls.Add(Me.SubtractionRadioButton) Me.OperationGroupBox.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.OperationGroupBox.Location = New System.Drawing.Point(200, 152) Me.OperationGroupBox.Name = "OperationGroupBox" Me.OperationGroupBox.Size = New System.Drawing.Size(120, 100) Me.OperationGroupBox.TabIndex = 2 Me.OperationGroupBox.TabStop = False Me.OperationGroupBox.Text = "Operation" ' 'AdditionRadioButton ' Me.AdditionRadioButton.Checked = True Me.AdditionRadioButton.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.AdditionRadioButton.Location = New System.Drawing.Point(8, 27) Me.AdditionRadioButton.Name = "AdditionRadioButton" Me.AdditionRadioButton.Size = New System.Drawing.Size(96, 24) Me.AdditionRadioButton.TabIndex = 0 Me.AdditionRadioButton.TabStop = True Me.AdditionRadioButton.Text = "&Addition" ' 'SubtractionRadioButton ' Me.SubtractionRadioButton.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.SubtractionRadioButton.Location = New System.Drawing.Point(8, 59) Me.SubtractionRadioButton.Name = "SubtractionRadioButton" Me.SubtractionRadioButton.TabIndex = 1 Me.SubtractionRadioButton.Text = "&Subtraction" ' 'AnswerTextBox ' Me.AnswerTextBox.AutoSize = False Me.AnswerTextBox.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(192, Byte)) Me.AnswerTextBox.Font = New System.Drawing.Font("Tahoma", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.AnswerTextBox.Location = New System.Drawing.Point(203, 40) Me.AnswerTextBox.Name = "AnswerTextBox" Me.AnswerTextBox.Size = New System.Drawing.Size(61, 27) Me.AnswerTextBox.TabIndex = 0 Me.AnswerTextBox.Text = "" Me.AnswerTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'SummaryGroupBox ' Me.SummaryGroupBox.Controls.Add(Me.CorrectLabel) Me.SummaryGroupBox.Controls.Add(Me.IdCorrectLabel) Me.SummaryGroupBox.Controls.Add(Me.IdIncorrectLabel) Me.SummaryGroupBox.Controls.Add(Me.IncorrectLabel) Me.SummaryGroupBox.Location = New System.Drawing.Point(336, 168) Me.SummaryGroupBox.Name = "SummaryGroupBox" Me.SummaryGroupBox.Size = New System.Drawing.Size(160, 79) Me.SummaryGroupBox.TabIndex = 4 Me.SummaryGroupBox.TabStop = False Me.SummaryGroupBox.Visible = False ' 'CorrectLabel ' Me.CorrectLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.CorrectLabel.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.CorrectLabel.Location = New System.Drawing.Point(11, 40) Me.CorrectLabel.Name = "CorrectLabel" Me.CorrectLabel.Size = New System.Drawing.Size(48, 23) Me.CorrectLabel.TabIndex = 1 Me.CorrectLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'IdIncorrectLabel ' Me.IdIncorrectLabel.AutoSize = True Me.IdIncorrectLabel.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.IdIncorrectLabel.Location = New System.Drawing.Point(72, 16) Me.IdIncorrectLabel.Name = "IdIncorrectLabel" Me.IdIncorrectLabel.Size = New System.Drawing.Size(72, 19) Me.IdIncorrectLabel.TabIndex = 2 Me.IdIncorrectLabel.Text = "Incorrect:" ' 'IncorrectLabel ' Me.IncorrectLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.IncorrectLabel.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.IncorrectLabel.Location = New System.Drawing.Point(75, 40) Me.IncorrectLabel.Name = "IncorrectLabel" Me.IncorrectLabel.Size = New System.Drawing.Size(48, 23) Me.IncorrectLabel.TabIndex = 3 Me.IncorrectLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'ProblemGroupBox ' Me.ProblemGroupBox.Controls.Add(Me.Label1) Me.ProblemGroupBox.Controls.Add(Me.LblSymbol) Me.ProblemGroupBox.Controls.Add(Me.TbxNum2) Me.ProblemGroupBox.Controls.Add(Me.TbxNum1) Me.ProblemGroupBox.Controls.Add(Me.ExitButton) Me.ProblemGroupBox.Controls.Add(Me.AnswerTextBox) Me.ProblemGroupBox.Controls.Add(Me.CheckAnswerButton) Me.ProblemGroupBox.Location = New System.Drawing.Point(24, 24) Me.ProblemGroupBox.Name = "ProblemGroupBox" Me.ProblemGroupBox.Size = New System.Drawing.Size(472, 104) Me.ProblemGroupBox.TabIndex = 0 Me.ProblemGroupBox.TabStop = False ' 'LblSymbol ' Me.LblSymbol.Font = New System.Drawing.Font("Arial Black", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LblSymbol.Location = New System.Drawing.Point(72, 40) Me.LblSymbol.Name = "LblSymbol" Me.LblSymbol.Size = New System.Drawing.Size(24, 23) Me.LblSymbol.TabIndex = 14 Me.LblSymbol.Text = "+" Me.LblSymbol.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'TbxNum2 ' Me.TbxNum2.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TbxNum2.Location = New System.Drawing.Point(99, 40) Me.TbxNum2.Name = "TbxNum2" Me.TbxNum2.Size = New System.Drawing.Size(48, 27) Me.TbxNum2.TabIndex = 13 Me.TbxNum2.Text = "" Me.TbxNum2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'TbxNum1 ' Me.TbxNum1.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TbxNum1.Location = New System.Drawing.Point(19, 40) Me.TbxNum1.Name = "TbxNum1" Me.TbxNum1.Size = New System.Drawing.Size(48, 27) Me.TbxNum1.TabIndex = 12 Me.TbxNum1.Text = "" Me.TbxNum1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center ' 'ExitButton ' Me.ExitButton.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.ExitButton.Location = New System.Drawing.Point(312, 64) Me.ExitButton.Name = "ExitButton" Me.ExitButton.Size = New System.Drawing.Size(128, 23) Me.ExitButton.TabIndex = 2 Me.ExitButton.Text = "E&xit" ' 'CheckAnswerButton ' Me.CheckAnswerButton.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.CheckAnswerButton.Location = New System.Drawing.Point(312, 24) Me.CheckAnswerButton.Name = "CheckAnswerButton" Me.CheckAnswerButton.Size = New System.Drawing.Size(128, 24) Me.CheckAnswerButton.TabIndex = 1 Me.CheckAnswerButton.Text = "&Check Answer" ' 'GradeGroupBox ' Me.GradeGroupBox.Controls.Add(Me.Grade1RadioButton) Me.GradeGroupBox.Controls.Add(Me.Grade2RadioButton) Me.GradeGroupBox.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GradeGroupBox.Location = New System.Drawing.Point(24, 152) Me.GradeGroupBox.Name = "GradeGroupBox" Me.GradeGroupBox.Size = New System.Drawing.Size(160, 100) Me.GradeGroupBox.TabIndex = 1 Me.GradeGroupBox.TabStop = False Me.GradeGroupBox.Text = "Grade" ' 'Grade1RadioButton ' Me.Grade1RadioButton.Checked = True Me.Grade1RadioButton.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Grade1RadioButton.Location = New System.Drawing.Point(8, 27) Me.Grade1RadioButton.Name = "Grade1RadioButton" Me.Grade1RadioButton.Size = New System.Drawing.Size(136, 24) Me.Grade1RadioButton.TabIndex = 0 Me.Grade1RadioButton.TabStop = True Me.Grade1RadioButton.Text = "Grade &1 (1-10)" ' 'Grade2RadioButton ' Me.Grade2RadioButton.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Grade2RadioButton.Location = New System.Drawing.Point(8, 59) Me.Grade2RadioButton.Name = "Grade2RadioButton" Me.Grade2RadioButton.Size = New System.Drawing.Size(144, 24) Me.Grade2RadioButton.TabIndex = 1 Me.Grade2RadioButton.Text = "Grade &2 (10-99)" ' 'MinusPictureBox ' Me.MinusPictureBox.Location = New System.Drawing.Point(48, 272) Me.MinusPictureBox.Name = "MinusPictureBox" Me.MinusPictureBox.Size = New System.Drawing.Size(16, 16) Me.MinusPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize Me.MinusPictureBox.TabIndex = 5 Me.MinusPictureBox.TabStop = False Me.MinusPictureBox.Visible = False ' 'NeutralPictureBox ' Me.NeutralPictureBox.Location = New System.Drawing.Point(120, 264) Me.NeutralPictureBox.Name = "NeutralPictureBox" Me.NeutralPictureBox.Size = New System.Drawing.Size(32, 32) Me.NeutralPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage Me.NeutralPictureBox.TabIndex = 7 Me.NeutralPictureBox.TabStop = False Me.NeutralPictureBox.Visible = False ' 'HappyPictureBox ' Me.HappyPictureBox.Location = New System.Drawing.Point(80, 264) Me.HappyPictureBox.Name = "HappyPictureBox" Me.HappyPictureBox.Size = New System.Drawing.Size(32, 32) Me.HappyPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage Me.HappyPictureBox.TabIndex = 7 Me.HappyPictureBox.TabStop = False Me.HappyPictureBox.Visible = False ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Arial Black", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(168, 40) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(24, 23) Me.Label1.TabIndex = 15 Me.Label1.Text = "=" Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'MathForm ' Me.AcceptButton = Me.CheckAnswerButton Me.AutoScaleBaseSize = New System.Drawing.Size(6, 16) Me.ClientSize = New System.Drawing.Size(520, 283) Me.Controls.Add(Me.OperationGroupBox) Me.Controls.Add(Me.NeutralPictureBox) Me.Controls.Add(Me.HappyPictureBox) Me.Controls.Add(Me.MinusPictureBox) Me.Controls.Add(Me.PlusPictureBox) Me.Controls.Add(Me.SummaryGroupBox) Me.Controls.Add(Me.GradeGroupBox) Me.Controls.Add(Me.ProblemGroupBox) Me.Controls.Add(Me.SummaryCheckBox) Me.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D Me.MaximizeBox = False Me.Name = "MathForm" Me.ShowInTaskbar = False Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Math Practice" Me.OperationGroupBox.ResumeLayout(False) Me.SummaryGroupBox.ResumeLayout(False) Me.ProblemGroupBox.ResumeLayout(False) Me.GradeGroupBox.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub ExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitButton.Click Me.Close() End Sub Private Sub CheckAnswerButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckAnswerButton.Click ' Event Click on the CheckAnswer Button 'If the Answer is correct show proper Message and clear the TextBox 'If Incorrect show proper Message and allow user to retry Dim a, b, c As Integer 'Will use for the Numbers and the Answer Static correct, incorrect As Integer 'Counters for the Summary a = Me.TbxNum1.Text b = Me.TbxNum2.Text c = Me.AnswerTextBox.Text If Me.SubtractionRadioButton.Checked = True Then 'Check if it's a substraction or adition If a - b = c Then 'Check if it's correct the Substraction MsgBox(" You are Correct", MsgBoxStyle.Exclamation, " Congratulations ") correct += 1 'Increment Correct Counter Me.TbxNum1.Text = "" Me.TbxNum2.Text = "" Me.AnswerTextBox.Text = "" Else MsgBox(" Sorry You are NOT Correct", MsgBoxStyle.Critical, " Try Again ...") Me.AnswerTextBox.SelectAll() incorrect += 1 'Increment Incorrect Counter End If Else ' Not a Substraction then it's an Addition If a + b = c Then 'Check if it's correct the Addition MsgBox(" You are Correct", MsgBoxStyle.Exclamation, " Congratulations ") correct += 1 'Increment Correct Counter Me.TbxNum1.Text = "" Me.TbxNum2.Text = "" Me.AnswerTextBox.Text = "" Else MsgBox(" Sorry You are NOT Correct", MsgBoxStyle.Critical, " Try Again ...") Me.AnswerTextBox.SelectAll() incorrect += 1 'Increment Incorrect Counter End If End If Me.IncorrectLabel.Text = incorrect Me.CorrectLabel.Text = correct End Sub Private Sub SummaryCheckBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SummaryCheckBox.Click ' Event Click on the Summary CheckBox 'If it's checked show Summary 'NOT checked do NOT show Summary If Me.SummaryCheckBox.Checked = True Then Me.SummaryGroupBox.Visible = True Else Me.SummaryGroupBox.Visible = False End If End Sub Private Sub SubtractionRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubtractionRadioButton.CheckedChanged Me.LblSymbol.Text = "-" End Sub Private Sub AdditionRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdditionRadioButton.CheckedChanged Me.LblSymbol.Text = "+" End Sub Private Sub AnswerTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles AnswerTextBox.KeyPress, TbxNum1.KeyPress, TbxNum2.KeyPress 'Allow only Numbers and Backspace in the textboxes If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then e.Handled = True End If End Sub End Class