Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Sum data read from text file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62327
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Sum data read from text file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Sum data read from text file - 7/11/2008 7:11:52 PM   
  meiliong

 

Posts: 1
Score: 0
Joined: 7/11/2008
Status: offline
Original message moved by dm_4ever
Reason : Moving to Appropriate Forum
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
 
 
Post #: 1
 
 RE: Sum data read from text file - 7/12/2008 12:47:32 PM   
  dm_4ever


Posts: 2666
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Get the values you read...convert them to integers using CInt() or a similar function and then add....not much to it really.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to meiliong)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Sum data read from text file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts