Option
Explicit
Dim
Zahl1
As
Double
Dim
Zahl2
As
Double
Dim
Ergebnis
As
Double
Private
Sub
CB_Berechnen_Click()
On
Error
GoTo
Fehler
Zahl1 =
CDbl
(TB_Zahl1.Text)
Zahl2 =
CDbl
(TB_Zahl2.Text)
If
IsNumeric(TB_Zahl1.Text)
And
IsNumeric(TB_Zahl2.Text)
Then
TB_Ergebnis = (TB_Zahl1.Text) + (TB_Zahl2.Text)
If
OB_Addition.Value =
True
Then
Ergebnis = Zahl1 + Zahl2
TB_Rechenart.Text =
"ADDITION"
TB_Ergebnis.Text = Format(Ergebnis,
"standard"
)
ElseIf
OB_Subtraktion.Value =
True
Then
Ergebnis = Zahl1 - Zahl2
TB_Rechenart.Text =
"SUBTRAKTION"
TB_Ergebnis.Text = Format(Ergebnis,
"standard"
)
ElseIf
OB_Multiplikation.Value =
True
Then
Ergebnis = Zahl1 * Zahl2
TB_Rechenart.Text =
"MULTIPLIKATION"
TB_Ergebnis.Text = Format(Ergebnis,
"standard"
)
ElseIf
OB_Division.Value =
True
Then
Ergebnis = Zahl1 / Zahl2
TB_Rechenart.Text =
"DIVISION"
TB_Ergebnis.Text = Format(Ergebnis,
"standard"
)
Else
If
Zahl2 = 0
Then
MsgBox (
"Bitte eine Zahl größer 0 eingeben!!"
)
CB_Neu_Click
Else
MsgBox (
"Rechenart auswählen!!"
)
CB_Neu_Click
End
If
End
If
Exit
Sub
Fehler:
MsgBox
" Bitte Werte eingeben!"
, vbCritical,
"Fehler 1"
End
Sub
Private
Sub
CB_Ende_Click()
End
End
Sub
Private
Sub
CB_Neu_Click()
TB_Zahl1.Text =
""
TB_Zahl2.Text =
""
TB_Ergebnis.Text =
""
TB_Zahl1.SetFocus
TB_Rechenart.Text =
""
End
Sub