Public Class frmArithmeticOperators
  Inherits System.Windows.Forms.Form
  Dim WhichOne As Integer  ' zmienna modułowa – określa wybór użytkownika

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
            System.EventArgs) Handles MyBase.Load
    RadioButton1.Checked = True
  End Sub

' Kolejne procedury nadają zmiennej WhichOne wartości odpowiadające
' działaniom arytmetycznym wskazanym przez użytkownika

  Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
    WhichOne = 1
  End Sub

  Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
    WhichOne = 2

  End Sub

  Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
    WhichOne = 3

  End Sub

  Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
    WhichOne = 4

  End Sub

  Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
    WhichOne = 5

  End Sub

  Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
    WhichOne = 6

  End Sub

  Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged
    WhichOne = 7

  End Sub

  Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged
    txtOperand2.Text = ""
    WhichOne = 8

  End Sub

  Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles RadioButton9.CheckedChanged
    txtOperand2.Text = ""
    WhichOne = 9

  End Sub
  Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As _
              System.EventArgs) Handles btnCalc.Click
    Select Case WhichOne
      Case 1
        txtResult.Text = CStr(CDbl(txtOperand1.Text) + _
               CDbl(txtOperand2.Text))  ' dodawanie
      Case 2
        txtResult.Text = CStr(CDbl(txtOperand1.Text) - _
               CDbl(txtOperand2.Text))  ' odejmowanie
      Case 3
        txtResult.Text = CStr(CDbl(txtOperand1.Text) * _
               CDbl(txtOperand2.Text))  ' mnożenie
      Case 4
        txtResult.Text = CStr(CDbl(txtOperand1.Text) / _
               CDbl(txtOperand2.Text))  ' dzielenie
      Case 5
        txtResult.Text = CStr(CInt(txtOperand1.Text) \ _
               CInt(txtOperand2.Text))  ' dzielenie całkowitoliczbowe
      Case 6
        txtResult.Text = CStr(CDbl(txtOperand1.Text) ^ _
               CDbl(txtOperand2.Text))  ' potęgowanie
      Case 7
        txtResult.Text = CStr(CInt(txtOperand1.Text) Mod _
               CInt(txtOperand2.Text))  ' reszta z dzielenia
      Case 8
        txtResult.Text = CStr(+(CDbl(txtOperand1.Text))) ' unarny plus
   
      Case 9
        txtResult.Text = CStr(-(CDbl(txtOperand1.Text))) ' unarny minus
    End Select
  End Sub

  Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As _
              System.EventArgs) Handles btnExit.Click
    Me.Dispose()   ' zakończenie programu
  End Sub

End Class
