A Function to Average a string of numbers?

# Thread: A Function to Average a string of numbers?

1. DZ
Junior Member
Join Date
Dec 1969
Posts
24

## A Function to Average a string of numbers?

Here is my string: <BR>myString = "2, 4, 10, 20" <BR><BR>is there a function, (or has someone designed one) that can give me the average of this string, ie:<BR>&#060;%=Avg(myString)%&#062;<BR><BR>any help you can send my way would be greatly appreciated. <BR>could you pleeeeze email me if you have somethin?<BR>Thanx! -ken<BR> webmaster@line9.com<BR>

2. Senior Member
Join Date
Dec 1969
Posts
745

## RE: A Function to Average a string of numbers?

&nbsp;<BR><BR>strnumber = "10000,6100,616"<BR><BR><BR>myray = split(strnumber,",")<BR><BR>mysum=0<BR><BR>for i = 0 to ubound(myray)<BR><BR> mysum = mysum + myray(i)<BR><BR>next <BR><BR><BR>myaverage = mysum/(ubound(myray)+1)<BR><BR>Response.write ("<BR> upper bound " & ubound(myray))<BR>Response.write("<BR> sum " & mysum)<BR><BR><BR><BR>response.write("<BR> average " & myaverage)<BR><BR><BR>

#### Posting Permissions

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