Sum of textboxes into label (loop?).
Posted by Beginner Bob on February 13, 2001 11:29 AM
I have the following which is the only thing I could come up with to work for what I'm trying to do:
Public Sub TOTIT()
Dim TB3 As Integer, TB4 As Integer, TB5 As Integer
On Error Resume Next
TB3 = TextBox3.Value
TB4 = TextBox4.Value
TB5 = TextBox5.Value
TTL = Format(TB3 + TB4 + TB5, "#,##0.00")
Label2.Caption = TTL
Is there any easy way to loop through the textboxes to get the sum (I will be adding many more textboxes). I've seen "For each TB in Userform1.Controls" loops here, but don't know exactly how I could use that to sum only the 3 textboxes and put the value in the label. Any help is greatly appreciated.