ich habe 3 Textboxen in Textbox1 soll das ergebnis von Txt3 und Text2 stehen. Es soll mir auch ein Minuswert anzeigen z. B. -123,36
Danke
If TextBox9.Text = "" Then
MsgBox "Bitte Preis pro Jahr eingeben!"
Else
TextBox18 = Application.WorksheetFunction.Round(CDbl(TextBox9.Text) * CDbl(TextBox10.Text) / _
365,XXX)
End If
End Sub
X=runden("ungerundeterWert" /100, 0)*100
Grüße
Debug.Print (Application.WorksheetFunction.Round(366 * 135.12, 1))
Debug.Print 366 * 135.12
Mal zum Testen Sag mal, was im direktfenster steht?
Sub Rundung()
Debug.Print (Application.WorksheetFunction.Round(366 * 135.12 / 365, 1))
Debug.Print (Application.WorksheetFunction.Round(366 * 135.12 / 365, 2))
Debug.Print 366 * 135.12 / 365
End Sub
Private Sub CommandButton1_Click()
Dim Ergebnis As Double
If TextBox9.Text = "" Then
MsgBox "Bitte Preis pro Jahr eingeben!"
Else
Ergebnis = CDbl(TextBox9.Text) * CDbl(TextBox10.Text) / 365
Ergebnis = WorksheetFunction.Round(Ergebnis, 2)
TextBox18 = Ergebnis
End If
End Sub
Gruß Werner
Private Sub CommandButton1_Click()
Dim Ergebnis As Double
If TextBox9.Text = "" Then
MsgBox "Bitte Preis pro Jahr eingeben!"
TextBox9.SetFocus
Else
Ergebnis = CDbl(TextBox9.Value) * CDbl(TextBox10.Value) / 365
Ergebnis = WorksheetFunction.Round(Ergebnis, 2)
TextBox18 = Ergebnis
TextBox9.SetFocus
End If
End Sub
Weiterhin solltest du bei Eigenschaften von TextBox18 Locked auf True stellen. TextBox18 ist ja ein reines Ausgabefeld in dem keine Änderungen möglich sein sollten.
TextBox18 = Ergebnis
durchTextBox18 = Format((Ergebnis), "#,##0.00")
Gruß Werner