top of page

The Code

 

 

 

 Public Class Form94

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

        '## Error Handling Routine of Non-Numeric Input ##

        '## Define Label as Invisible until Error is Triggered ##
        LabelErrorMessage.Visible = False

        '## Dimension Numeric Variable as Single Precision ##
        Dim FirstNumber As Single
        Dim
SecondNumber As Single
        Dim
DivisionalSum As Single

        '## Error_Handler Triggered : If Entry is Non-Numeric ##
        On Error GoTo Error_Handler

        '## Assign Text.Box Input to Numeric Variables ##
        FirstNumber = Numeric1.Text
        SecondNumber = Numeric2.Text

        '## Assign Numeric Variables to Label.Text ##
        LbNumeric1.Text = FirstNumber
        LbNumeric2.Text = SecondNumber

        '## Compute Divisional Sum of FirstNumber & SecondNumber ##
        DivisionalSum = (FirstNumber / SecondNumber)

        '## Assign DivisionalSum to (Label - LbDivisionalSum.Text) ## 
        LbDivisionalSum.Text = DivisionalSum

        '## Error Triggered Exit Sub ##
        Exit Sub

Error_Handler:
     
  '## ErrorHandling Sub Routine[1] ##
        ErrorHandling()
        
    End Sub

    '## Sub[1] ##

    Sub ErrorHandling()


        '## Error Handling Routine ##
        LbDivisionalSum.ForeColor = Color.Red
       
LbDivisionalSum.Text = "Error"

        '## Declare LabelErrorMessage as Visible ##
        LabelErrorMessage.Visible = True
       
LabelErrorMessage.ForeColor = Color.Red
       
LabelErrorMessage.Text = "One or Both Entries is/are Non-Numeric! Try Again"

    End Sub

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

        '## Reset ForeColor = Color.Blue ##
        LbDivisionalSum.ForeColor = Color.Blue


        '## Reset Number Variables to Null Value ##
        LbNumeric1.Text = ""
       
LbNumeric2.Text = ""
       
LbDivisionalSum.Text = ""
       
Numeric1.Text = ""
       
Numeric2.Text = ""


    End Sub

End Class
 

   
 

Website Links-173.jpg
bottom of page