Skip to content

Instantly share code, notes, and snippets.

@mritzmann
Created December 2, 2014 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mritzmann/8e8a2adf2264c09b6da9 to your computer and use it in GitHub Desktop.
Save mritzmann/8e8a2adf2264c09b6da9 to your computer and use it in GitHub Desktop.
VBA Taschenrechner
' Lizenz: Public Domain
' Autor: Markus Ritzmann
Public Ausgabe1 As Byte 'Damit Variable Sub-Uebergreifend gespeichert wird
Public Operator As String 'Damit Variable Sub-Uebergreifend gespeichert wird
Private Sub cmd0_Click()
txt.Text = txt.Text & 0
End Sub
Private Sub cmd1_Click()
txt.Text = txt.Text & 1
End Sub
Private Sub cmd2_Click()
txt.Text = txt.Text & 2
End Sub
Private Sub cmd3_Click()
txt.Text = txt.Text & 3
End Sub
Private Sub cmd4_Click()
txt.Text = txt.Text & 4
End Sub
Private Sub cmd5_Click()
txt.Text = txt.Text & 5
End Sub
Private Sub cmd6_Click()
txt.Text = txt.Text & 6
End Sub
Private Sub cmd7_Click()
txt.Text = txt.Text & 7
End Sub
Private Sub cmd8_Click()
txt.Text = txt.Text & 8
End Sub
Private Sub cmd9_Click()
txt.Text = txt.Text & 9
End Sub
Private Sub cmddelete_Click()
txt.Text = "" 'Anzeigefeld leeren
End Sub
Private Sub cmddividieren_Click()
Ausgabe1 = txt.Text
txt.Text = ""
Operator = "/"
End Sub
Private Sub cmdenter_Click()
Ausgabe2 = txt.Text
Select Case Operator
Case "+"
Ergebnis = Ausgabe1 + Ausgabe2
Case "-"
Ergebnis = Ausgabe1 - Ausgabe2
Case "*"
Ergebnis = Ausgabe1 * Ausgabe2
Case "/"
Ergebnis = Ausgabe1 / Ausgabe2
End Select
txt.Text = Ergebnis
End Sub
Private Sub cmdmal_Click()
Ausgabe1 = txt.Text
txt.Text = ""
Operator = "*"
End Sub
Private Sub cmdminus_Click()
Ausgabe1 = txt.Text
txt.Text = ""
Operator = "-"
End Sub
Private Sub cmdplus_Click()
Ausgabe1 = txt.Text
txt.Text = ""
Operator = "+"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment