Gruppe
Dialog
Bereich
TextBox
Thema
TextBoxes- und Label-Werte in Abhängigkeit verändern
Problem
Wie kann ich in einer UserForm die Werte von Labels und TextBoxes in Abhängigkeit voneinander verändern?
Lösung
Geben Sie den nachfolgenden Code in das Klassenmodul der UserForm ein.
ClassModule: Tabelle11
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
ClassModule: frmKredit
Private Sub cmdContinue_Click()
Unload Me
End Sub
Private Sub txtTilgung_Change()
Dim dRate As Double, dTilgung As Double
Dim iPreis As Integer
If txttilgung.Text = "" Then
txtrate.Text = ""
Label2.Caption = ""
Exit Sub
End If
iPreis = CInt(Label1.Caption)
dRate = CDbl(txttilgung.Text) / 100
txtrate.Text = WorksheetFunction.RoundUp(iPreis * dRate, 2)
dTilgung = CDbl(txtrate.Text)
Label2.Caption = WorksheetFunction.RoundUp(iPreis / dTilgung, 0)
End Sub
Private Sub txtRate_Change()
Dim iPreis As Integer
Dim dTilgung As Double
If txtrate.Text = "" Then
txtrate.Text = ""
Label2.Caption = ""
Exit Sub
End If
iPreis = CInt(Label1.Caption)
dTilgung = CDbl(txtrate.Text)
txttilgung.Text = WorksheetFunction.RoundUp(dTilgung * 100 / iPreis, 2)
Label2.Caption = WorksheetFunction.RoundUp(iPreis / dTilgung, 0)
End Sub
StandardModule: basMain
Sub CallForm()
frmKredit.Show
End Sub