Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input File: Reading X lines then quitting 1

Status
Not open for further replies.

ToeJamNEarl

Programmer
Jan 26, 2004
91
US
Hey guys,

I am using an File System Object for reading/writing Input/Output files for my application, and I was wondering how would I make it so that if the program has read 100 lines and hasn't encountered a specific string (ie. "NEXT FILE") to exit out of the program?

Appreciate the help.

-Diran
 
'Set the textfile to read:
set ts = fso.opentextfile("mytextfile.txt",forreading)
for i = 1 to 100
myLine = ts.readline
if cbool(instr(lcase(myLine), "next file"))=true then
ts.close
goto skipSection
end if
ts.movenext
next i
'Text not found, so close the file, and then close the form
ts.close
unload me

SkipNext:
'Carry on with coding, as the text has been found.

Hope this helps. I'm not at the VB PC, so I can't test this bit, but you get the idea.

BB
 
Hey BB,

I tried something similar to what you had and I get the following error:

-2147217887, Multiple-step operation generated errors. Check each status value., Microsoft Cursor Engine

The format for this error message:
Err.Number, Err.Description, Err.source

Any ideas would be great.

Some insight to this program is as follows:

I create an offline ADODB.Recordset and I have the program read in a line, and then store fragments of the currently read line into the recordset I have created. Then from there it reads the portions of the table and stores the found values into an array.

Hope that provides some insight. Cause I can't figure this error out, and a google search so far speaks of SQL related issues, which I do not make any SQL calls at all.

Thanks.

-Diran
 
The SQL calls are what places the data into and retrieves from the dataset. Even though you don't use SQL to make these calls, they are generated when they interact with datasets.

Can you post your code?

BB
 
BB,

I figured it out.

The input line that was trying to be stored to my table was bigger than that I set it to.

My table was set to maxchar 72, whereas the input line was 81 characters.

I appreciate your help BB, you get a *.

Thanks Much,

-Diran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top