Step Through a Text Document

mlr0911

Registered User.
Local time
Today, 07:27
Joined
Oct 27, 2006
Messages
155
Hello all,

I am working on a project that requires me to write code to access a text document and import that information into a database that is user friendly. I have code in place already to retrieve some of the information needed. However, I am having issues getting the next line of data in a text document.

How would I go to the next line in the document retrieve that information but stop when it see's the word "TOTAL" and loop through the whole document?


Thanks in advance for your help.
 
Toal is in the text line. I have isolated this string before with the following:
Left(strpage,10)="TOTAL").
 
This is from the Access Help file with the added line to check for TOTAL.

Dim InputData
Open "MYFILE" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Check for end of file.
Line Input #1, InputData ' Read line of data.
If Instr(InputData,"TOTAL") <> 0 Then Exit Do
Debug.Print InputData ' Print to the Immediate window.
Loop
Close #1 ' Close file.
 
Thanks PDX_MAN

How would I capture the text between line "A" and "D"? Example

Line A="TEST"------this has been captured into the tablen already. If line A="Test" then move to line B & C & possibly D through Z and capture the data and stop if any line = "TOTAL".

Thanks in advance for your help.
 
Not sure I understand ... perhaps you are looking for a counter?

Dim InputData
Dim MyCounter AS Integer
MyCounter = 1
Open "MYFILE" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Check for end of file.
Line Input #1, InputData ' Read line of data.
If Instr(InputData,"TOTAL") <> 0 Then Exit Do
If MyCounter > 4 Then
:
Do Something
:
End If
MyCounter = MyCounter + 1
Debug.Print InputData ' Print to the Immediate window.
Loop
Close #1 ' Close file.
 
Thanks again for your help PDX……………………….Let me show you what I am trying to accomplish.

Here is an example of the text that is being searched.

Fund: YUI
Account: YUI China
000004321
123456788
002340000
Total: $34,504.20


I already have written code that captures the Fund and the Account. Now, I am trying to go to the next lines which are numbers and capture them (they are always different). The stopping point for this particular example would be “Total” (which captures the data and places it into the table) before going on to the rest of the document.

Thanks again for your help.
 
I guess I am not understanding what the problem is. If you are able to read the first line, and the second line, why can't you read the third and subsequent lines?

What do you get in the Immediate (Debug) window if you run this?

Dim InputData
Dim MyCounter AS Integer

Open "MYFILE" For Input As #1 ' Open file for input.
Line Input #1, InputData ' Read line of data.
Debug.Print InputData
Close #1

It may be an issue with how the data is stored in the text file. Try changing Line Input #1
to
Input #1
 

Users who are viewing this thread

Back
Top Bottom