Greetings...
I found the following code somewhere on the net, I forget where, that will convert a text file from Unix format to DOS format. However, if the file is too big, you get an overflow error when you pass the string to the function.
Here is the code for Lf2Crlf:
here is the section of the code I'm using to call the above function:
This works great in nearly every instance, but if the file being passed to it is too large, then it doesn't run.
Since Access reads the entire Unix formatted file in as a line, it tries to pass the entire file to the above function as a line.... and that give an Overflow error.
I could just take the pertanent portions from this function and put them into every function that I call it from... but that would not be modular. If it comes to it, I will...
Any help would be appreciated
GComyn
I found the following code somewhere on the net, I forget where, that will convert a text file from Unix format to DOS format. However, if the file is too big, you get an overflow error when you pass the string to the function.
Here is the code for Lf2Crlf:
Code:
Public Function Lf2Crlf(InputString As String, StringLength As Integer) As String
'InputString is the string to convert
'StringLength is the length of the string
Dim InstrPos As Long
Dim StartPos As Integer
StartPos = 1
InstrPos = InStr(StartPos, InputString, vbLf)
Do Until InstrPos = 0
'insert the CRLF
InputString = Left(InputString, InstrPos - 1) & vbCrLf & Right(InputString, Len(InputString) - InstrPos)
StartPos = InstrPos + 2
InstrPos = InStr(StartPos, InputString, vbLf)
Loop
Lf2Crlf = InputString
End Function
here is the section of the code I'm using to call the above function:
Code:
...
intInputFileNumber = FreeFile
intOutputFileNumber = FreeFile + 1
Open strSourceFile For Input As #intInputFileNumber
Open strPathName & strNewFileName For Output As #intOutputFileNumber
Do While Not EOF(intInputFileNumber)
Line Input #intInputFileNumber, strLine
If Len(strLine) = 0 Then strLine = " "
strLine = Lf2Crlf(strLine, Len(strLine)) '** This is where the error occurs
Print #intOutputFileNumber, strLine
Loop
Close
...
This works great in nearly every instance, but if the file being passed to it is too large, then it doesn't run.
Since Access reads the entire Unix formatted file in as a line, it tries to pass the entire file to the above function as a line.... and that give an Overflow error.
I could just take the pertanent portions from this function and put them into every function that I call it from... but that would not be modular. If it comes to it, I will...
Any help would be appreciated
GComyn