SmokinWrek
IS-IT--Management
Howdy! I hope someone can help me out here. I've got the following code that is supposed to
read in a file of fixed length records, and reverse its order.
When I try to run this, I get the following error on the Get statement:
Run-time error '59':
Bad record length
I have verified that before the GET statement processes, that x=13068, RecordSize = 400,
and len(InputData) = 400.
I'm probably overlooking something obvious, but could someone please help me out?
read in a file of fixed length records, and reverse its order.
Code:
OutFile = txtOutputFilename.Text
InFile = txtInputFilename.Text
TotalCount = fso.GetFile(InFile).Size / RecordSize
RecNum = TotalCount
CurrentCount = 0
InputData = String(RecordSize, Chr(64))
Open InFile For Random As #1 Len = RecordSize
Set OutStream = fso.OpenTextFile(OutFile, ForWriting, True)
For x = RecNum To 1 Step -1
Get #1, x, InputData
OutStream.Write InputData
CurrentCount = CurrentCount + 1
If ((CurrentCount Mod 1000) = 0) Then
lblCounter.Caption = CurrentCount & " of " & TotalCount & _
" records completed."
DoEvents
End If
Next x
When I try to run this, I get the following error on the Get statement:
Run-time error '59':
Bad record length
I have verified that before the GET statement processes, that x=13068, RecordSize = 400,
and len(InputData) = 400.
I'm probably overlooking something obvious, but could someone please help me out?