Forum

Notifications
Clear all

TextBox SUM

3 Posts
2 Users
0 Reactions
106 Views
(@meunome)
Posts: 2
New Member
Topic starter
 

Hey, everybody,

I would like to know if you can help me code to SUM the 6 textbox values, they are UserFormCustomer, MultiPage and the textBox with the names "txtAmountInv1", "txtAmountInv2" .etc. Values ​​are populated with this procedure:

Private sub txtPerUnitInv6_Change()

               Dim q As Double

               Dim t As Double

                           If IsNumeric (txtPerUnitInv6.Value) Then

                           If txtPerUnitInv6.Value <> "" Then t =

                            txtPerUnitInv6.Value

                           If txtQty6.Value <> "" Then q = txtQty6.Value

                            txtAmountInv6.Value = t * q

                          End if

                               If txtPerUnitInv6.Value = "" Then

                      txtAmountInv6.Value = ""

                   End if

    End Sub

There are 4 more text boxes- txtAmountExpense1,txtAmountExpense2, etc. In the same MultiPage, the values ​​are filled in manually. I want to ADD txtSub-Total plus the values ​​of 4 texBox. The SUM must appear in the textbox called txtTotalGeral. Thank you very much.

 
Posted : 13/12/2021 8:29 pm
(@debaser)
Posts: 836
Member Moderator
 

The basic code could be something like this:

 

Dim counter as long

for counter = 1 to 4

Dim RunningTotal as Double

RunningTotal = RunningTotal + CDbl("0" & Me.controls("txtAmountExpense" & n).Text)

Next counter

RunningTotal = RunningTotal + CDbl("0" & Me.controls("txtSub-Total").Text)

txtTotalGeral.Text = RunningTotal

 
Posted : 14/12/2021 6:06 am
(@meunome)
Posts: 2
New Member
Topic starter
 

thanks for trying to help.

 
Posted : 14/12/2021 12:26 pm
Share: