I wanted to know how do I remove blank lines from text file. Any help will be appreciated.
Here are a few examples of how to remove special characters in strings. The first one ought to do the trick. replace(sString,vbcrlf,"") replace(sString,Chr(13),"") replace(sString,Chr(10),"")
I have already tried with that but it was of no use. Any other way to do it.
Chances are your text file is using another control character to signify an end of line or new line. Chr(13),Chr(10) combinations are the most common but some systems use others. You'll probably have to write a little program to evaluate the ASC() code of each character in the file. Make the loop stop on characters outside the range of alphabetical or punctuation characters. This help you identify which character to perform the replace on. I've seen this problem the most when working with files brought over to windows from UNIX machines. But, my previous reply works in most cases.
I tried with that also. You know a strage thing is happening. When I do asc() it wont show asc code for blank lines at all. Would you like to have a look at my txt file.
Email it to info@eggheadcafe.com
Here's the asp and yes it works fine. < Dim oFS Dim oFSTxt Dim sString Set oFS = Server.CreateObject("Scripting.FileSystemObject") Set oFSTxt = oFS.OpenTextFile("c:\inetpub\wwwroot\test.txt") sString = oFSTxt.ReadAll Set oFS = Nothing sString = Trim(sString) sString = Replace(sString, Chr(13), "") sString = Replace(sString, Chr(10), "") response.write sString on error resume next Set oFSTxt = nothing Set oFS = nothing %>