top of page

The Code

 

 

 

Public Class Form92

    '## Private Sub RadioRandom Routine ##
    '## RadioButton.Checked Mathematical Random Argumentation ##
    '## Incorporate Subroutines [1 to 3]                      ##
    '## ----------------------------------------------------- ## 

    '## Private Sub RadioOperator Routine ##
    '## RadioButton.Checked Mathematical Operator Selection ##
    '## Incorporates Subroutines [4 to 6]                   ##
    '## --------------------------------------------------- ##

    '## Private Sub RandomArgument Rountine ##
    '## If Test... Then... Else...          ##
    '## Incorporates Subroutines [7 to 8]   ##

    '## On Error Goto Error_Handler --------##
    '## Numeric Variables Input Only -------##
    '## Incorporates Subroutine [9] ---------##
    '## ----------------------------------- ##

    '## Private Sub RandomArgument Button Calcus  ##
    '## Formulate Mathematical Argument Labelling ##
    '## ----------------------------------------- ##

    '## Private Sub InitialClear Button at Startup ##
    '## Clears Labels at Startup Procedure ------- ##
    '## Labels were named during Program Procedure ##

    '## -------------------------------------------##

    '## Private Sub ClearValues.Button ------------- ##
    '## Clear Numeric Variables to Zero ------------ ##
    '## Clear AlhpaNumberic Variables to Null String  ##

    '## ----------------------------------------- ##


    '## Dimension Variable in Public Class ------------ ##
    '## For Transitioning through Programing Sub Stages ##

    Dim a, b As Integer
    Dim
Answer As Single
    Dim
TT As Integer
    Dim
MathSign As String
    Dim
Correct As String = "Correct"
    Dim
Incorrect As String = "Incorrect"
    Dim
CountCorrect As Integer
    Dim
CountIncorrect As Integer

    Private Sub RadioRandom_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If RadioButton1.Checked Then
           
'## Subroutine[1] Random1Variable ##
            Random1Variable()

        ElseIf RadioButton2.Checked Then
           
'## Subroutine[2] Random2Variable ##
            Random2Variable()

        Else

            '## Subroutine[3] Random3Variable ##
            Random3Variable()

        End If

        '## Assign Random Variable to Label.Text ##
        LbRandoma.Text = a
       
LbRandomb.Text = b

    End Sub

    '## SubRountines 1 to 3 -----------------------##

    '## Sub[1] ##
    Sub Random1Variable()
       
a = (10 * Rnd() + 10)
       
b = (10 * Rnd() + 10)
    End Sub

    '## Sub[2] ##
    Sub Random2Variable()
       
a = (20 * Rnd() + 10)
       
b = (20 * Rnd() + 10)
    End Sub

    '## Sub[3] ##
    Sub Random3Variable()
       
a = (30 * Rnd() + 10)
       
b = (30 * Rnd() + 10)
    End Sub

    '## -------------------------------------------##

    Private Sub RadioOperator_Click(sender As Object, e As EventArgs) Handles Button2.Click

        If RadioAddition.Checked Then
           
'## Subroutine[4] Addition Argument ##
            AdditionArgument()

        ElseIf RadioSubtraction.Checked Then
         
  '## Subroutine[5] Subtraction Argument ##
            SubtractionArgument()

        Else

            '## Subroutine [6] Multiplication Argument ##
            MultiplicationArgument()

        End If

        '## Assign Random Variable to Label.Text ##
        Sign.Text = MathSign

    End Sub

    '## SubRountines 4 to 6 -----------------------##

    '## Sub[4] ##
    Sub AdditionArgument()
       
TT = a + b
        MathSign = Chr(43)
     
  '## Asc(+) Addition Sign ##
    End Sub

    '## Sub[5] ##
    Sub SubtractionArgument()
       
TT = a - b
        MathSign = Chr(45)
       
'## Asc(-) Minus Sign ##
    End Sub

    '## Sub[6] ##
    Sub MultiplicationArgument()
       
TT = a * b
        MathSign = Chr(120)
       
'## Asc(x) Multiply Sign ##
    End Sub

    '## -------------------------------------------##

    Private Sub RandomArgument_Click(sender As Object, e As EventArgs) Handles Button4.Click

        '## Formulation Mathematical Argument Labelling ##

 

        '## Error Handling : Non-Numeric Input -------- ##
       
On Error GoTo Error_Handler
       
       
 Answer = AnswerBox.Text

        If Answer = TT Then
           
LbCorrect.Text = Correct
            '## Subrountine [7] Count No. Correct ##
            NumberCorrect()
            

        Else


            LbIncorrect.Text = Incorrect
            '## SubRountine [8] Count No. Incorrect ##
            NumberIncorrect()
            
        End If


        LbAnswer.Text = TT

        '## Non-Numeric Triggers Error_Handler ##
        '## Exit Sub ------------------------- ##

        Exit Sub

Error_Handler:
       
'## Subroutine [9] Error Handling Parrameters ##
        '## Triggered by Non-Numeric Input ---------- ##
        '## ForeColor Labels = Color.Red ------------ ##

        HandleErrors()

    End Sub

    '## Sub[7] ##
    Sub NumberCorrect()
       
CountCorrect = CountCorrect + 1
       
LbCountCorrect.Text = CountCorrect
    End Sub

    '## Sub[8] ##
    Sub NumberIncorrect()
       
CountIncorrect = CountIncorrect + 1
       
LbCountIncorrect.Text = CountIncorrect
    End Sub

   '## Sub[9] ##
    Sub HandleErrors()
       
'## AnswerBox.Text Error Font-------##
        AnswerBox.ForeColor = Color.Red
        AnswerBox.Text = "Error"
       
'##---------------------------------##
        '## LbAnswer.Text Error Font--------##

        LbAnswer.ForeColor = Color.Red
        LbAnswer.Text = "Enter Numeric Value"
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


         Form89.Show()
        Me.Hide()


    End Sub

    Private Sub InitialClear_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        '## Clear Labelling Content at Startup Procedure ##
        '## Clear Numeric Variables to Zero ------------ ##
        '## Clear AlhpaNumberic Variables to Null String ##

        LbRandoma.Text = ""
       
LbRandomb.Text = ""

        MathSign = ""
       
Sign.Text = ""
       
AnswerBox.Text = ""
       
LbAnswer.Text = ""
       
LbCorrect.Text = ""
     
  LbIncorrect.Text = ""
       
LbCountCorrect.Text = ""
       
LbCountIncorrect.Text = ""

    End Sub

    Private Sub ClearValues_Click(sender As Object, e As EventArgs) Handles Button5.Click

        '## Clear Numeric Variables to Zero ------------ ##
        '## Clear AlhpaNumberic Variables to Null String ##

        a = 0
       
b = 0
       
TT = 0
       
Answer = 0
       
LbRandoma.Text = ""
       
LbRandomb.Text = ""

        MathSign = ""
       
Sign.Text = ""
       
AnswerBox.Text = ""
       
LbAnswer.Text = ""
        

        '## ------------------------------------- ##
        '## Reset AnswerBox.Text Font = Blue ---- ##

        '## Reset LbAnswer.Text Font = Blue ----- ##
        '## Error_Handler Triggered Color.Red ---- ##

        AnswerBox.ForeColor = Color.Blue

        LbAnswer.ForeColor = Color.Blue

    End Sub

End Class

 

 

 

Website Links-173.jpg
bottom of page