Hab hier mal einen Taschenrechner Programmiert:
Brauche hilfe bei den Buttons MC, MR, MS M+ M- einfach nach ganz unten scrollen und mir bitte helfen!
Jetzt wollte ich noch Buttons wie beim Normalen Taschenrechner machen also: MC, MR, MS, M+ ,M-
Und noch ein Msgbox wo das M angezeigt würd wenn man auf z.b MR oder MS clickt wenn man auf MC clickt sollte das M weggehn.
Nun brauche ich die codes und was ihr so reinschreiben würdet damit die buttons funktionieren.
Bitte um hilfe bei denn Buttons Danke
Brauche hilfe bei den Buttons MC, MR, MS M+ M- einfach nach ganz unten scrollen und mir bitte helfen!
Visual Basic:
Dim FirstNumber As Double
Dim SecondNumber As Double
Dim AnswerNumber As Double
Dim ArithmeticProcess As String
Dim Zahl As Double
Dim Op As String
Private Sub cmd0_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "0"
Else
txtDisplay.Text = txtDisplay.Text & 0
End If
End Sub
Private Sub cmd1_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "1"
Else
txtDisplay.Text = txtDisplay.Text & 1
End If
End Sub
Private Sub cmd2_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "2"
Else
txtDisplay.Text = txtDisplay.Text & 2
End If
End Sub
Private Sub cmd3_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "3"
Else
txtDisplay.Text = txtDisplay.Text & 3
End If
End Sub
Private Sub cmd4_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "4"
Else
txtDisplay.Text = txtDisplay.Text & 4
End If
End Sub
Private Sub cmd5_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "5"
Else
txtDisplay.Text = txtDisplay.Text & 5
End If
End Sub
Private Sub cmd6_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "6"
Else
txtDisplay.Text = txtDisplay.Text & 6
End If
End Sub
Private Sub cmd7_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "7"
Else
txtDisplay.Text = txtDisplay.Text & 7
End If
End Sub
Private Sub cmd8_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "8"
Else
txtDisplay.Text = txtDisplay.Text & 8
End If
End Sub
Private Sub cmd9_Click()
If txtDisplay.Text = "0" Then
txtDisplay.Text = "9"
Else
txtDisplay.Text = txtDisplay.Text & 9
End If
End Sub
Private Sub cmdb_Click()
If txtDisplay.Text <> "0123456789" Then
If InStr(txtDisplay.Text, "") = 0 Then
txtDisplay.Text = "-" & txtDisplay.Text
Else
txtDisplay.Text = Left(txtDisplay.Text, Len(txtDisplay.Text) - 1)
End If
End If
End Sub
Private Sub cmdhoch2_Click()
If txtDisplay.Text <> "0123456789" Then
txtDisplay.Text = (txtDisplay.Text * txtDisplay.Text)
End If
End Sub
Private Sub cmdplusminus_Click()
If txtDisplay.Text <> "" Then
If InStr(txtDisplay.Text, "-") = 0 Then
txtDisplay.Text = "-" & txtDisplay.Text
Else
txtDisplay.Text = Right(txtDisplay.Text, Len(txtDisplay.Text) - 1)
End If
End If
End Sub
Private Sub cmdpunkt_Click()
If InStr(txtDisplay.Text, ",") = 0 Then
If txtDisplay.Text = "0" Then
txtDisplay.Text = ","
Else
txtDisplay.Text = txtDisplay.Text & ","
End If
End If
End Sub
Private Sub cmdlöschen_Click()
txtDisplay.Text = " "
End Sub
Private Sub cmdplus_Click()
FirstNumber = Val(Replace(txtDisplay.Text, ",", "."))
txtDisplay.Text = ""
ArithmeticProcess = "+"
Op = "+"
End Sub
Private Sub cmdgleich_Click()
SecondNumber = Val(Replace(txtDisplay.Text, ",", "."))
If Op = "+" Then
AnswerNumber = FirstNumber + SecondNumber
End If
If Op = "-" Then
AnswerNumber = FirstNumber - SecondNumber
End If
If Op = "X" Then
AnswerNumber = FirstNumber * SecondNumber
End If
If Op = "/" Then
If SecondNumber = "0" Then
MsgBox "Man kann nicht mit Null teilen", 16, "Achtung"
Exit Sub
End If
AnswerNumber = FirstNumber / SecondNumber
End If
txtDisplay.Text = AnswerNumber
End Sub
Private Sub cmdminus_Click()
FirstNumber = Val(Replace(txtDisplay.Text, ",", "."))
txtDisplay.Text = ""
Op = "-"
cmdpunkt.Enabled = True
End Sub
Private Sub cmdmal_Click()
FirstNumber = Val(Replace(txtDisplay.Text, ",", "."))
txtDisplay.Text = " "
Op = "X"
cmdpunkt.Enabled = True
End Sub
Private Sub cmddurch_Click()
FirstNumber = Val(Replace(txtDisplay.Text, ",", "."))
txtDisplay.Text = " "
Op = "/"
cmdpunkt.Enabled = True
End Sub
Private Sub cmdwurzel_Click()
If txtDisplay.Text = "" Then
MsgBox ("Es befindet sich noch kein Wert")
Else
txtDisplay.Text = Val(txtDisplay.Text) ^ 0.5
End If
End Sub
Jetzt wollte ich noch Buttons wie beim Normalen Taschenrechner machen also: MC, MR, MS, M+ ,M-
Und noch ein Msgbox wo das M angezeigt würd wenn man auf z.b MR oder MS clickt wenn man auf MC clickt sollte das M weggehn.
Nun brauche ich die codes und was ihr so reinschreiben würdet damit die buttons funktionieren.
Visual Basic:
Private Sub M_Change() Ist die MsgBox wo das M hin soll wenn man auf MR oder MS clickt
M.Text = "M"
End Sub
Private Sub MC_Click() Sollte dann das M weggehn
If txtM.Text = "M" Then
txtDisplay.Text = ""
End If
End Sub
Private Sub MM_Click()
Zahl = Val(Replace(txtDisplay.Text, ",", ".")) Der M- Button beim Rechner
End Sub
Private Sub MP_Click()
Zahl = Val(Replace(txtDisplay.Text, ",", ".")) Der M+ Button beim Rechner
End Sub
Private Sub MR_Click()
Zahl = Val(Replace(txtDisplay.Text, ",", ".")) Das Ergebnis MR button beim Rechner
End Sub
Private Sub MS_Click()
Zahl = Val(Replace(txtDisplay.Text, ",", ".")) Der button wo alle eingegeben Sachen gespeichert werden MS button
End Sub
Zuletzt bearbeitet von einem Moderator: