Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding elements of an array

Status
Not open for further replies.

MichelleNO

Programmer
Dec 2, 1999
1
US
I have an array with three elements in it. How do I add these elements and then average them?
 
Here is the code. <br>
<br>
============================================<br>
<br>
Dim a(3) As Integer<br>
Dim i As Integer, j As Integer<br>
<br>
a(1) = 75<br>
a(2) = 125<br>
a(3) = 400<br>
<br>
For i = 1 To 3<br>
j = j + a(i)<br>
Next i<br>
<br>
MsgBox &quot;sum of array A is &quot; & Str(j) & &quot; average is &quot; & Str(j / 3)<br>
<br>
<br>
============================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top