Connecting Tech Pros Worldwide Help | Site Map

Sum data read from text file

Newbie
 
Join Date: Jul 2008
Posts: 8
#1: Jul 12 '08
I had written a simple script using vbscript to read text file data line by line. On top of that i would like to grab the read data and perform calculation such as get the total sum. The data that i read is an integer. How should i continue from this? For example the data i got from this script are 1,2,3,4,5 i need to sum all these datas 1+2+3+4+5=15. Please help. Thank you

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\test2\test.txt", ForReading)

Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")
For i = 3 to Ubound(arrServiceList)
Wscript.Echo "Service: " & arrServiceList(i)
Next
Loop
Reply