Hi all
I have a small project, that includes reading ASCII txt files with invoice information, the files contain all the information needed, but its NOT consequent on each side. The file is used after reading as an input to a access code who then generates the invoices thru a report generator.
When I have inconsequent output from the txt files the generator will not print correct information on each page,(the pagebreak in the generator failes regards to fixed pagebreak)and the information printed is rubbish.
I need a code to search for a given word or caracter and then put that line to a fixed line, and push all the txt below this line down including the search txt.
## Deliverables
Here is the code that i am using.
Function Prep() As Integer
Dim lngInFile As Long
Dim lngOutFile As Long
Dim strIn As String
Dim strOut As String
Dim lngCounter As Long
Dim intPos As Integer
Dim strReplace As String
Dim dooloop As Long
Dim PageBreak As Boolean 'True/False variable to tell if its the
Dim GoToLine As Integer
Dim LineCount As Integer 'Counter for current line number
lngInFile = FreeFile
Open "D:\ERGO\FA\BIN\[login to view URL]" For Input As lngInFile
lngOutFile = FreeFile
Open "D:\ERGO\FA\BIN\[login to view URL]" For Output As lngOutFile
While Not EOF(lngInFile)
Line Input #lngInFile, strIn
intPos = InStr(strIn, " LISTE")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = (" LISTE2") & vbCrLf
'do something...
strIn = Replace(strIn, " LISTE1", strReplace, , 1)
intPos = InStr(strIn, " LISTE1")
Wend
intPos = InStr(strIn, "Totalt ")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = "Totalt: "
'do something...
strIn = Replace(strIn, "Totalt ", strReplace, , 1)
intPos = InStr(strIn, "Totalt ")
strIn = vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
vbCrLf & vbCrLf & vbCrLf & vbCrLf & strIn
Wend
intPos = InStr(strIn, "Side: 2")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = "Side : 2"
'do something...
strIn = Replace(strIn, "Side: 2", strReplace, , 1)
intPos = InStr(strIn, "Side: 2")
strIn = vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
vbCrLf & vbCrLf & vbCrLf & vbCrLf & strIn
Wend
intPos = InStr(strIn, " ----------------")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = " "
'do something...
strIn = Replace(strIn, " ----------------", strReplace, , 1)
intPos = InStr(strIn, " ----------------")
Wend
intPos = InStr(strIn, " 8398 10 03791")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = (" 8398 10 03791") & vbCrLf & (Chr(12))
'do something...
strIn = Replace(strIn, " 8398 10 03791", strReplace, , 1)
intPos = InStr(strIn, " 8398 10 03791")
Wend
intPos = InStr(strIn, "?")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = "?"
'do something...
strIn = Replace(strIn, "?", strReplace, , 1)
intPos = InStr(strIn, "?")
Wend
intPos = InStr(strIn, "?")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = "?"
'do something...
strIn = Replace(strIn, "?", strReplace, , 1)
intPos = InStr(strIn, "?")
Wend
intPos = InStr(strIn, "›")
While intPos > 0
lngCounter = lngCounter + 1
strReplace = "?"
'do something...
strIn = Replace(strIn, "›", strReplace, , 1)
intPos = InStr(strIn, "›")
Wend
intPos = InStr(strIn, "†")
While intPos > 0
lngCounter = lngCounte
## Platform
Windows 2000, Access2000, VB6