Login | |
|
 |
RE: read fixed length text file and add totals - 8/14/2006 11:49:27 PM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
|
I still don't see how you could take one of the lines that you have posted, read 3233 characters from it and have it display a number like 15 or 20. Oh well, either way, try replacing this line: Wscript.Echo strCharacters with this: nTotal = nTotal + CInt(strCharacters) Then after you have looped through the entire file stick in this line: WScript.Echo nTotal
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: read fixed length text file and add totals - 8/15/2006 1:32:35 AM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
|
Most likely you are trying to read past the end of the file. The best bet for help is to post a sample of the file you are parsing, the code that you are using, what you are trying to accomplish, and the error (with line number) that you are getting. Otherwise we are just shooting in the dark trying to help you.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: read fixed length text file and add totals - 8/17/2006 12:23:05 AM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
|
I think your best bet would be to do this without using Skips. Try this: Set objFSO = createObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("d:\MBR\718.txt", 1) arrLines = Split(objFile.ReadAll, vbCrLf) For Each strLine In arrLines nTotal = nTotal + Mid(strLine, 34, 2) Loop Set objFSO = Nothing WScript.Echo nTotal objFile.Close
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: read fixed length text file and add totals - 8/22/2006 2:37:35 AM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
|
Ok, I stopped trying to do it in my head and played with it some. This looks like it works to me: Set objFSO = createObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("d:\MBR\718.txt", 1) arrLines = Split(objFile.ReadAll, vbCrLf) For Each strLine In arrLines strSegment = Mid(strLine, 35, 2) If Not strSegment = "" Then nThisOne = (CInt(Mid(strSegment, 1, 1)) * 10) + (CInt(Mid(strSegment, 2, 1))) nTotal = nTotal + nThisOne End If Next Set objFSO = Nothing WScript.Echo nTotal objFile.Close
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|