Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 22033

How do I find the in a text file?

$
0
0
I am trying to read lines from a text file and transmit them to a distant location to reconstruct the file. I have no control over how the files were written. Sometimes the last line has <CR><LF>, sometimes <CR>, sometimes <LF>, and sometimes no termination characters. “Line Input” doesn’t input the <CR><LF>. I have tried using Seek before and after “Line Input” and comparing that with the length of the input string as shown in the following code.

Code:


  Open gstrTxPCDir & gstrTxPCFileName For Input As #TextUDLFNum

more code

            lngPosBeforeRead = Seek(TextUDLFNum)
            Line Input #TextUDLFNum, strOneLine
            lngPosAfterRead = Seek(TextUDLFNum)
            intLen = Len(strOneLine)
            MsgBox "lngPosBeforeRead = " & lngPosBeforeRead _
                & vbCrLf & "lngPosAfterRead = " & lngPosAfterRead _
                & vbCrLf & "intLen = " & intLen _
                & vbCrLf & "strOneLine = " & strOneLine

I know what to do if there are two extra characters or no extra characters but one extra character is ambiguous.
Is there an easier way to solve this than opening the file in binary and reading one character at a time?

Viewing all articles
Browse latest Browse all 22033

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>