| PictureBox (Textausgabe), IsNumeric |
| |
| |
| Dim StartKapital As Currency, Laufzeit As Integer, Zinssatz As Single, Jahre As Integer |
| |
| Private Sub cmdRechnen_Click() | |
| With txtStartKapital | Die Eingabefelder bekommen nach Klick auf den |
| .SelStart = 0 | Rechnen-Button Fokus auf die gesamte Textlänge. |
| .SelLength = Len(.Text) | |
| .SetFocus | |
| End With | |
| With txtLaufzeit | |
| .SelStart = 0 | |
| .SelLength = Len(.Text) | |
| End With | |
| With txtZinssatz | |
| .SelStart = 0 | |
| .SelLength = Len(.Text) | |
| End With | |
| |
| If Len(txtStartKapital.Text) = 0 Or IsNumeric(txtStartKapital) = False Or txtStartKapital.Text = "0" Then |
| MsgBox "Bitte einen Wert für das Startkapital eingeben!", Title:="Fehler bei der Eingabe" |
| txtStartKapital.SetFocus | |
| Exit Sub | |
| End If | |
| StartKapital = CCur(txtStartKapital.Text) | |
| |
| If Len(txtLaufzeit.Text) = 0 Or IsNumeric(txtLaufzeit) = False Or txtLaufzeit.Text = "0" Then |
| MsgBox "Bitte einen Wert für die Laufzeit eingeben!", Title:="Fehler bei der Eingabe" |
| txtLaufzeit.SetFocus | |
| Exit Sub | |
| End If | |
| Laufzeit = CCur(txtLaufzeit.Text) | |
| |
| If Len(txtZinssatz.Text) = 0 Or IsNumeric(txtZinssatz) = False Or txtZinssatz.Text = "0" Then |
| MsgBox "Bitte einen Wert für den Zinssatz eingeben!", Title:="Fehler bei der Eingabe" |
| txtZinssatz.SetFocus | |
| Exit Sub | |
| End If | |
| Zinssatz = CCur(txtZinssatz.Text) | |
| |
| picAusgabe.AutoRedraw = True | |
| picAusgabe.Cls | Der Cls-Befehl löscht "alte Werte" im Bildfeld. |
| picAusgabe.Print " Zinsberechnung vom " & Now |
| picAusgabe.Print " ==============================" |
| picAusgabe.Print " Kapital = " & StartKapital; " DM; Laufzeit = " & Laufzeit; " Jahre; Zinssatz = " & Zinssatz; " %" |
| picAusgabe.Print "" | |
| picAusgabe.Print Tab(3); "Ihr Vermögen beträgt:" | |
| For Jahre = 1 To Laufzeit | |
| StartKapital = StartKapital * (1 + Zinssatz / 100) | |
| picAusgabe.Print Tab(5); "im "; Jahre & ". Jahr"; Tab(30); Format(StartKapital, "Currency") |
| Next | |
| End Sub | |
| |
| Private Sub Form_Resize() | Das Bildfeld muss sich selbst zeichnen können. |
| picAusgabe.AutoRedraw = True | Die innere Höhe des Ergebnisses erhält einen Wert, |
| picAusgabe.Height = Me.Height * 3.75 | der 375% der äußeren Höhe des Formulars entspricht. |
| picAusgabe.Width = Me.Width * 0.85 | Die innere Breite des Bildfeldes erhält einen Wert, der |
| End Sub | 85% der äußeren Breite des Formulars entspricht. |
| Fokus ist auf Rechnen-Button. |
| Private Sub cmdRechnen_KeyPress(KeyAscii As Integer) |
| If KeyAscii = 27 Then Unload Me | Bei Drücken der Esc-Taste wird das Formular entladen. |
| End Sub | |
| |
| Private Sub picAusgabe_KeyPress(KeyAscii As Integer) | Fokus ist auf der Bildausgabe. |
| If KeyAscii = 27 Then Unload Me | Bei Drücken der Esc-Taste wird das Formular entladen. |
| End Sub | |
| |
| Private Sub txtLaufzeit_KeyPress(KeyAscii As Integer) | Fokus ist auf Eingabefeld Laufzeit. |
| If KeyAscii = 27 Then Unload Me | Bei Drücken der Esc-Taste wird das Formular entladen. |
| End Sub | |
| Fokus ist auf Eingabefeld Startkapital. |
| Private Sub txtStartKapital_KeyPress(KeyAscii As Integer) |
| If KeyAscii = 27 Then Unload Me | Bei Drücken der Esc-Taste wird das Formular entladen. |
| End Sub | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| Private Sub Form_KeyPress(KeyAscii As Integer) | Fokus ist auf Formular. |
| If KeyAscii = 27 Then Unload Me | Bei Drücken der Esc-Taste wird das Formular entladen. |
| End Sub | |
| |