Results 1 to 6 of 6

Thread: Finding Average of 3 Numbers excluding zeros

Threaded View

  1. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Finding Average of 3 Numbers excluding zeros

    You could just use a brutal application of logic:
    Code:
    Dim a As Single
    Dim b As Single
    Dim c As Single
    Dim d As Single
    a = Val(txtValueA.Text)
    b = Val(txtvalueB.Text)
    c = Val(txtValueC.Text)
    Select Case True
        Case a <> 0 And b <> 0 And c <> 0
            d = (a + b + c) / 3
        Case a <> 0 And b <> 0, a <> 0 And c <> 0, b <> 0 And c <> 0
            d = (a + b + c) / 2
        Case Else
            d = a Or b Or c
    End Select
    Debug.Print "Average: "; d
    I think that works, but it's getting late here
    Last edited by Doogle; Aug 18th, 2012 at 02:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width