I have 13 TextBoxs aligned in a column, txtNetWeight(0) - txtNetWeight(12), yes they are indexed.
As each one loses focus I want to add all the ones before it to get a sum. Then put that sum into a TextBox named txtGrossWeight, not indexed.
I have this;
That works but is uglyCode:Private Sub txtNetWeight_LostFocus(Index As Integer) Dim lngSum As Long Dim lngAdd1 As Long Dim lngAdd2 As Long If txtNetWeight(Index) = "" Then txtNetWeight(Index) = "0" End If For X = txtNetWeight.LBound To txtNetWeight.UBound If txtNetWeight(X) <> "" Then If X = 0 Then txtGrossWeight = txtNetWeight(0) lngSum = txtNetWeight(0) Else lngAdd1 = txtNetWeight(X) lngAdd2 = lngSum lngSum = lngAdd1 + lngAdd2 txtGrossWeight = lngSum End If End If Next X End Suband I am sure it can be done easier. Anyone have an idea.
Thanks,
Tommy




and I am sure it can be done easier. Anyone have an idea.
Reply With Quote