Re: VB6 to convert textfile data
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Tue, 19 Sep 2006 14:16:03 -0500
"Al" <Al@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
I am having difficulty solving a textfile import issue.
Upon completion, I want to covert the VB6 program to an .exe file and
schedule to run through a batch file on a daily basis. I have other files
like this running through a VB6 conversion program and batch file setup but I
have encountered a snag with this one.
See if this will do as you want:
LFS
'[ Form1 code ]
Option Explicit
Private Keys As New Collection
Private Sub Command1_Click()
Const DataFile = "D:\temp\data.txt"
Const FixedFile = "D:\temp\fixed.txt"
Dim src As Long, dst As Long
Dim txt As String
src = FreeFile
Open DataFile For Input Access Read As src Len = 4096
dst = FreeFile
Open FixedFile For Output Access Write As dst Len = 1024
Do While Not EOF(src)
Line Input #src, txt
Print #dst, Adjusted(txt)
Loop
Close
End Sub
Private Function Adjusted(Text As String) As String
Dim cnt As Long, list As Collection
Dim key As String, match As String
' Extract search data
match = Left$(Text, 8)
key = Mid$(Text, 10, 8)
' Find key list
On Error Resume Next
Set list = Keys(key)
If Err.Number Then
' New list
Set list = New Collection
Err.Clear
End If
' Find match in current list
cnt = list(match)
If Err.Number Then
' No match
cnt = list.Count + 1
' Save value for this Key/Match pair
list.Add cnt, match
' Replace old list with new list
Keys.Remove key
Keys.Add list, key
End If
' Adjust text
Mid$(Text, 19, 3) = Format$(cnt, "000")
Adjusted = Text
End Function
.
- Follow-Ups:
- Re: VB6 to convert textfile data
- From: Al
- Re: VB6 to convert textfile data
- Prev by Date: RTF printing problem
- Next by Date: Re: simple textbox label question
- Previous by thread: Re: VB6 to convert textfile data
- Next by thread: Re: VB6 to convert textfile data
- Index(es):
Relevant Pages
|