You may want to try somethign more like this
Edit: Never mind, the post above is a better way to go.Code:If Val(txtValueA.Text) = 0 Then If Val(txtValueB.Text) = 0 Then If Val(txtValueC.Text) = 0 Then 'No Valid entries above 0 txtAverage.Text ="0" Else txtAverage.Text = Val(txtValueC.Text) End If Else If Val(txtValueC.Text) = 0 Then 'Only b is valid txtAverage.Text = Val(txtValueB.Text) Else 'B and C are valid txtAverage.Text = Round(((Val(txtValueB.Text) + Val(txtValueC.Text)) / 2), 2) End If End If Else If Val(txtValueB.Text) = 0 Then If Val(txtValueC.Text) = 0 Then 'Only A is valid txtAverage.Text = Val(txtValueA.Text) Else 'Only A and C are valid txtAverage.Text = Round(((Val(txtValueA.Text) + Val(txtValueC.Text)) / 2), 2) End If Else If Val(txtValueC.Text) = 0 Then 'Only a and b are valid txtAverage.Text = Round(((Val(txtValueB.Text) + Val(txtValueB.Text)) / 2), 2) Else ' all are valid txtAverage.Text = Round(((Val(txtValueA.Text) + Val(txtValueB.Text) + Val(txtValueC.Text)) / 3), 2) End If End If End If
You still may want to look over the If structure in this post though to get an idea of the logic




Reply With Quote