Option Explicit
Public Sub CommandButton1_Click()
Dim Ctrl As Control
Dim Res As Double
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.TextBox And Ctrl.Name <> "TextBox4" Then
Res = Res + Format(CDbl(Ctrl.Text), "##,###,##0.00")
End If
Next Ctrl
TextBox4.Text = Format(Res, "##,###,##0.00") & " €"
Res = Empty
If Not IsNumeric(TextBox4.Text) Then Exit Sub
[A1].Offset(, 1) = TextBox4.Value
Me.Hide
End Sub
Public Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Value <> 0 Then
If [A1] = Empty Then
[A1] = Label1.Caption & "=" & Format(TextBox1.Value, "##,###,##0.00") & " €"
Else
[A1] = [A1] & "; " & Label1.Caption & "=" & Format(TextBox1.Value, "##,###,##0.00") & " €"
End If
TextBox1.Value = Format(TextBox1.Value, "##,###,##0.00") & " €"
End If
End Sub
Public Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox2.Value <> 0 Then
If [A1] = Empty Then
[A1] = Label2.Caption & "=" & Format(TextBox2.Value, "##,###,##0.00") & " €"
Else
[A1] = [A1] & "; " & Label2.Caption & "=" & Format(TextBox2.Value, "##,###,##0.00") & " €"
End If
TextBox2.Value = Format(TextBox2.Value, "##,###,##0.00") & " €"
End If
End Sub
Public Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox3.Value <> 0 Then
If [A1] = Empty Then
[A1] = Label3.Caption & "=" & Format(TextBox3.Value, "##,###,##0.00") & " €"
Else
[A1] = [A1] & "; " & Label3.Caption & "=" & Format(TextBox3.Value, "##,###,##0.00") & " €"
End If
TextBox3.Value = Format(TextBox3.Value, "##,###,##0.00") & " €"
End If
End Sub
Private Sub UserForm_Activate()
Dim i As Byte
For i = 1 To 4
Me.Controls("TextBox" & i) = ""
Next i
End Sub