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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TEXT FILE STRING HANDLING

Status
Not open for further replies.

IncredibleVolk

Technical User
Apr 2, 2004
67
US
I can't understand why this doesn't work and I was hoping someone can help me. I want to exclude certain lines from a text file based on conditions. This is giving me a result when I print out the msgbox but the file I'm writing to is coming up empty. Basically I want to keep everything where the line is at least 45 characters but I want to exclude lines where a certain position in the string contains information.

if Len(strCurrentLine) > 45 and len(Mid(strCurrentLine, 36, 6)) = 0 then
objFilesTarget.WriteLine strCurrentLine
 
Like this ?
If Len(strCurrentLine) > 45 And Trim(Mid(strCurrentLine, 36, 6)) = "" Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank You PHV. That worked great. Now I have another problem. Does it allow for an "OR" correlation? I was removing another line that started to the far left using this:

strcomp(left(strCurrentLine,1)," ") = 0

Is there a way that could be added to this?

If Len(strCurrentLine) > 45 And Trim(Mid(strCurrentLine, 36, 6)) = "" Then
 
you can have as many And's and Or's as you see fit.
just do the old maths thing and put () round them for your sake and for precedence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top