Change Event für 25 TextBoxen
22.09.2016 08:31:06
Franz
nachfolgendes Change Ereignis steht jeweils in den TextBoxen 4 bis 28!
Dies möchte ich nun vereinfachen, in dem ich einer Art Schleife einbaue, sodass ich das Change_Event nur einmal aufrufen muss. Eventuell kann man das auch über eine Klasseninstanz lösen.
Danke für eure Hilfe
Private Sub TextBox4_Change()
Dim iTB As Long
If IsNumeric(TextBox4.Value) = False Then TextBox4.Value = "0"
For iTB = 4 To 28
With Controls("TextBox" & iTB)
If .Text = "" Then .Text = "0"
If .Text "0" Then
.ForeColor = &H0&
Else
.ForeColor = &HFFFFFF
End If
End With
Next iTB
Call TB_rechnen
End Sub
Sub TB_rechnen()TextBox3.Text = CDbl(TextBox4) + CDbl(TextBox5) + CDbl(TextBox6) + CDbl(TextBox7) + CDbl(TextBox8) + CDbl(TextBox9) _
+ CDbl(TextBox10) + CDbl(TextBox11) + CDbl(TextBox12) + CDbl(TextBox13) + CDbl(TextBox14) + CDbl(TextBox15) _
+ CDbl(TextBox16) + CDbl(TextBox17) + CDbl(TextBox18) + CDbl(TextBox19) + CDbl(TextBox20) _
+ CDbl(TextBox21) + CDbl(TextBox22) + CDbl(TextBox23) + CDbl(TextBox24) + CDbl(TextBox25) + CDbl(TextBox26) _
+ CDbl(TextBox27) + CDbl(TextBox28)
End Sub