PDA

View Full Version : [SOLVED:] Count textbox values greater than 0



agfac
12-18-2013, 06:13 PM
Hi,

I wonder to count textbox values greater than 0 and I made this code but it's not working.

Could someone help me please?

Thanks


Dim i As Integer
Dim divisor As Integer

divisor = 0

For i = 1 To 11
If ("TextBox" & i).Value > 0 Then
divisor = dividor + 1
End If
Next i


Dim soma As Long

soma = TextBox1.Value + TextBox2.Value + TextBox3.Value + TextBox4.Value + TextBox5.Value + TextBox6.Value + TextBox7.Value + TextBox8.Value + TextBox9.Value + TextBox10.Value + TextBox11.Value

Label203.Caption = soma \ divisor

Bob Phillips
12-18-2013, 06:23 PM
Dim i As Integer
Dim divisor As Integer

divisor = 0

For i = 1 To 11
If Me.Controls("TextBox" & i).Value > 0 Then
divisor = dividor + 1
End If
Next i


Dim soma As Long

soma = TextBox1.Value + TextBox2.Value + TextBox3.Value + TextBox4.Value + TextBox5.Value + TextBox6.Value + TextBox7.Value + TextBox8.Value + TextBox9.Value + TextBox10.Value + TextBox11.Value

Label203.Caption = soma \ divisor

agfac
12-18-2013, 08:28 PM
It works!

Thanks