Hello Everyone,

I need help to figure out how to associate a select case statement with, which point to four Function procedures, to four radio buttons that are used to +, -, *, and / two simple fractions in a fractions calculator. This is a class assignment for which I have already been graded. I used an If...ElseIf statment and it worked perfectly. Now I am trying to utilize the Case Statments with Function Procedures to do the same thing. I do not get graded for this, but I was told to research it an find an answer. My book has not helped me. Please help. Anything you can do to assist me would be appreciated. My current code is listed below.

Option Strict On

Public Class frmFractionsCalculator

' Class variables declared

Private decFractionOne As Decimal
Private decFractionTwo As Decimal
Private decResult As Decimal

Private Sub btnCalculateResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateResult.Click
' This event handler allows the user to enter two simple fractions
' and calculate them returning a result in decimal format to the hundredths
' place. This handler will also prevent the user from dividing by zero.

' Deaclare and initalize variables
Dim decFractionOneNumerator As Decimal
Dim decFractionOneDenominator As Decimal
Dim decFrationTwoNumerator As Decimal
Dim decFractionTwoDenominator As Decimal


' Try-Catch SystemException validation for thw numerators and demoninators
Try
decFractionOneNumerator = Convert.ToDecimal(Me.txtFractionOneNumerator.Text)
decFractionOneDenominator = Convert.ToDecimal(Me.txtFractionOneDenominator.Text)
decFrationTwoNumerator = Convert.ToDecimal(Me.txtFractionTwoNumerator.Text)
decFractionTwoDenominator = Convert.ToDecimal(Me.txtFractionTwoDenominator.Text)
Catch Exception As SystemException
MsgBox("Error. Please try again", , "Error")
Me.txtFractionOneNumerator.Focus()
Me.txtFractionOneNumerator.Clear()
Me.txtFractionOneDenominator.Clear()
Me.txtFractionTwoNumerator.Clear()
Me.txtFractionTwoDenominator.Clear()
End Try

' Try-Catch DivideByZeroException validation
Try
decFractionOne = decFractionOneNumerator / decFractionOneDenominator
decFractionTwo = decFrationTwoNumerator / decFractionTwoDenominator
Catch Exception As DivideByZeroException
MsgBox("Attempted to divide by zero", , "Error")
Me.txtFractionOneNumerator.Focus()
Me.txtFractionOneNumerator.Clear()
Me.txtFractionOneDenominator.Clear()
Me.txtFractionTwoNumerator.Clear()
Me.txtFractionTwoDenominator.Clear()
End Try

Select Case decResult
Case 0
Addition()
Case 1
Subtraction()
Case 2
Multiplication()
Case 3
Division()
End Select

' Display calculation results
Me.lblResults.Visible = True
Me.lblResults.Text = decResult.ToString("F2")

End Sub

' Function Procedure Addition
Private Function Addition() As Decimal
decResult = decFractionOne + decFractionTwo
Return decResult
End Function

' Function Procedure Subtraction
Private Function Subtraction() As Decimal
decResult = decFractionOne - decFractionTwo
Return decResult
End Function

' Function Procedur Multiplication
Private Function Multiplication() As Decimal
decResult = decFractionOne * decFractionTwo
Return decResult
End Function

' Function Procedur Division
Private Function Division() As Decimal
decResult = decFractionOne / decFractionTwo
Return decResult
End Function

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
' This event handler clears the calculator form and sets the focus
' on the first fractions numerator and the +(Plus) radio button.

Me.txtFractionOneNumerator.Text = " "
Me.txtFractionOneDenominator.Text = " "
Me.txtFractionTwoNumerator.Text = " "
Me.txtFractionTwoDenominator.Text = " "
Me.lblResults.Text = " "
Me.radPlus.Checked = True
Me.radMinus.Checked = False
Me.radMultiply.Checked = False
Me.radDivide.Checked = False
Me.txtFractionOneNumerator.Focus()
End Sub

Private Sub frmFractionsCalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(5000)
' This event handler pauses the splash screen for five seconds and loads
' the form clearing the calculator form and setting the focus
' on the first fractions numerator and the +(Plus) radio button.

Me.txtFractionOneNumerator.Focus()
Me.txtFractionOneNumerator.Text = " "
Me.txtFractionOneDenominator.Text = " "
Me.txtFractionTwoNumerator.Text = " "
Me.txtFractionTwoDenominator.Text = " "
Me.lblResults.Text = " "
Me.radPlus.Checked = True
Me.radMinus.Checked = False
Me.radMultiply.Checked = False
Me.radDivide.Checked = False

End Sub
End Class