Zinssatz berechnen II

Formel (Potenzierung)
Private Sub Form_Load()
   ZinsSatzBerechnung
End Sub
Sub ZinsSatzBerechnung()
   Dim StartKapital As Currency
   Dim EndKapital As Currency
   Dim Zinssatz As Single
   Dim Jahre As Integer
   Dim Button As Integer
      StartKapital = InputBox("Geben Sie das Startkapital ein")
      EndKapital = InputBox("Geben Sie das Endkapital ein")
      Jahre = InputBox("Wie lange sollte die Laufzeit sein?", Default:="10")
      Zinssatz = 100 * (EndKapital / StartKapital) ^ (1 / Jahre) - 100
   MsgBox "Der Zinssatz beträgt " & Format(Zinssatz / 100, "Percent")
      Button = MsgBox("Berechnung wiederholen?", Buttons:=vbOKCancel + vbQuestion)
   If Button = vbOK Then
      ZinsSatzBerechnung
   Else
      Unload Me
   End If
End Sub
Private Sub Form_Click() Eine andere Variante, bei der Fehler abgefangen werden.
Gogo:
   Dim StartKapital, EndKapital, Zinssatz, Laufzeit, Button
   Me.AutoRedraw = True
StartKapitalEingabe:
   StartKapital = InputBox("Geben Sie das Startkapital ein: ")
   If StartKapital = "" Then
      MsgBox "Bitte einen Betrag eingeben!", Buttons:=vbExclamation
      GoTo StartKapitalEingabe
   End If
EndKapitalEingabe:
   EndKapital = InputBox("Geben Sie das Endkapital ein: ")
   If EndKapital = "" Then
      MsgBox "Bitte einen Betrag eingeben!", Buttons:=vbExclamation
      GoTo EndKapitalEingabe
   End If
LaufzeitEingabe:
   Laufzeit = InputBox("Laufzeit?:", Default:="10")
   If Laufzeit = "" Then
      MsgBox "Bitte Laufzeit eingeben!", Buttons:=vbExclamation
      GoTo LaufzeitEingabe
   End If
   Zinssatz = 100 * (EndKapital / StartKapital) ^ (1 / Laufzeit) - 100
   MsgBox "Der Zinssatz muß " & Format(Zinssatz / 100, "Percent") & " betragen!"
      Button = MsgBox("Berechnung wiederholen?", Buttons:=vbOKCancel + vbQuestion)
   If Button = vbOK Then
      GoTo Gogo
   Else
      Unload Me
   End If
End Sub
.



 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info