Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 4th, 2010, 11:00 AM   #1
jaacmmason
Newbie
 
Join Date: Feb 2010
Posts: 11
Rep Power: 0 jaacmmason is on a distinguished road
Calculations based on reading in seperate text file

Hello all. I am working on updating a process that takes in a pdf file, converts it to a txt file and then reads the txt file, does some calculations, and creates a report sent via e-mail. Everything is working great except for the calculations. It was set up to read a specific line, but that rule no longer holds true for us.

I currently have this code for the calculations:
While Not totalsFile.AtEndOfStream
line = totalsFile.Readline
If (usingSCO = True) Then
If (lineNo = 13) Then
If (InStr(line, " ") > 0) Then
totalAmount = totalAmount + Replace(Split (line) (0), "$", "")
Else
totalAmount = totalAmount + Replace(line, "$", "")
End If
End If
If (InStr(line, "Item Count (CR/DB)") > 0) Then
For Each i In Split(line)
If (IsNumeric(i)) Then
totalItems = totalItems + i
End If
Next
End If
Else
If (lineNo = 13) Then
Dim tempArray
tempArray = Split(line)
totalAmount = totalAmount + tempArray(UBound(tempArray) - 1)
End If

if (inStr(line,,"Credits Debits Difference") > 0) then
line = totalsFile(uBound(totalsFile) - 6)
For Each i In Split(line)
if (IsNumeric(i)) then
totalItems = totalItems + i
End if
Next
Else
totalItems = 1234 ' Added just to see if line was being found
End If
End If
lineNo = lineNo + 1
Wend

Everything works fine EXCEPT for the final calculation starting with " if (inStr(line,,"Credits Debits Difference") > 0) then". The line I am looking for is 2 lines below this line I have found. I am having problems getting the calculation as that line has not yet been read. I tried to add to the line count, but when I completed the calculation, it just added 2 to the end of the total number of lines in the file. The calculated line I am trying to get to is always the 6th line from the bottom, but it is on a different line from the top, and it always has 2 seperate entries on it, and always numeric.
I tried to read to the end of the file and then go up 6 lines, but that did not work for me either.
Any help anyone could offer would be GREATLY appreciated! I have been working on this for a few days and it seems like such a simple problem to fix. Much thanks in advance of any suggestions!
jaacmmason is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading in a Text File zeppelin57 Java 7 Nov 14th, 2008 2:12 AM
Reading text from a file. ShawnStovall C++ 8 May 26th, 2008 4:02 PM
help me please : text file based dictionary with c bankster C 5 Feb 24th, 2008 2:22 PM
Reading contents of text file then printing out, not working. chillypacman PHP 5 Jun 19th, 2006 6:29 AM
reading a random line from a text file cloud- Visual Basic 11 Apr 8th, 2005 1:34 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC