Option
Explicit
Private
Sub
CB_Berechnen_Click()
Dim
Zahl1#, Zahl2#, Ergebnis#
If
IsNumeric(Trim(TB_Zahl1.Text)) =
False
_
Or
IsNumeric(Trim(TB_Zahl2.Text)) =
False
_
Then
MsgBox
"Bitte numerische Werte eingeben!"
, vbExclamation,
"Achtung!"
Exit
Sub
End
If
Zahl1 =
CDbl
(Trim(TB_Zahl1.Text))
Zahl2 =
CDbl
(Trim(TB_Zahl2.Text))
If
Zahl2 = 0#
And
OB_Division.Value =
True
Then
MsgBox
"Division durch Null!"
, vbCritical,
"Achtung!"
Exit
Sub
End
If
If
OB_Addition.Value =
True
Then
Ergebnis = Zahl1 + Zahl2
TB_Rechenart.Text =
"ADDITION"
ElseIf
OB_Subtraktion.Value =
True
Then
Ergebnis = Zahl1 - Zahl2
TB_Rechenart.Text =
"SUBTRAKTION"
ElseIf
OB_Multiplikation.Value =
True
Then
Ergebnis = Zahl1 * Zahl2
TB_Rechenart.Text =
"MULTIPLIKATION"
ElseIf
OB_Division.Value =
True
Then
Ergebnis = Zahl1 / Zahl2
TB_Rechenart.Text =
"DIVISION"
Else
MsgBox (
"Rechenart auswählen!"
), vbExclamation,
"Achtung!"
Exit
Sub
End
If
TB_Ergebnis.Text = Format(Ergebnis,
"standard"
)
End
Sub