|
-
Aug 14th, 2004, 12:48 AM
#1
Thread Starter
Lively Member
Ok some more hlp plz
I need VB to scan a .txt for a certain line fo text
then i need to make Num = 1 if that text is there or 0 if not (which i can do, not the question) then if num = 1 print the lines i want and if it = 0 then close and say msgbox "Already set up for use"
so all i need to know is how to scan a .txt for a certain line of text..thanks
--Semper Fi--
--Area 61 Admin--
-
Aug 14th, 2004, 01:06 AM
#2
the INSTR() function will search text
a search turned up this:
http://www.vbforums.com/showthread.p...light=instring
-
Aug 14th, 2004, 08:08 AM
#3
InStr() will work if the text is in memory, which is not what you are saying. However, it is what you SHOULD have been saying. Don't bother trying to scan a text file as a file, I'm not sure that it can be done, and it would be a pain in the but anyways.
The thing to do, is read the file line by line, and scan each line with InStr(). If you cannot be sure that the string you want lies on a single line, you will have to look for part of the string on one line, and part of the string on a second line, which is slower and tougher, but doable.
It may seem like reading in the file would be slower than searching for the text in the file, but it isn't. Consider that the program would have to read the file to search it, anyways.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|