CalculatorForm::btnCalculate_Click PHP Method

btnCalculate_Click() protected method

Perform the necessary operations on the operands, and output the value to the lblResult
protected btnCalculate_Click ( $strFormId, $strControlId, $strParameter )
    protected function btnCalculate_Click($strFormId, $strControlId, $strParameter)
    {
        switch ($this->lstOperation->SelectedValue) {
            case 'add':
                $mixResult = $this->txtValue1->Text + $this->txtValue2->Text;
                break;
            case 'subtract':
                $mixResult = $this->txtValue1->Text - $this->txtValue2->Text;
                break;
            case 'multiply':
                $mixResult = $this->txtValue1->Text * $this->txtValue2->Text;
                break;
            case 'divide':
                $mixResult = $this->txtValue1->Text / $this->txtValue2->Text;
                break;
            default:
                throw new Exception('Invalid Action');
        }
        $this->lblResult->Text = '<b>Your Result:</b> ' . $mixResult;
    }