
02-21-2003, 05:04 PM
|
 |
Centurion
|
|
Join Date: Dec 2002
Location: Washington State, USA
Posts: 131
|
|
Saving text file to a specific directory
|
I have a program that opens a file for random access. When processing this file sometimes I want to save a copy of the file to a specific directory. How do I do this?
Code:
Sub CheckRawData()
Dim Transaction As TransactionNew
Dim FileNum As Integer
Dim RecordLen As Long
Dim Position As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'SET LINE POSITION AND OPEN RAW FILE
Position = 2
RecordLen = Len(Transaction)
FileNum = FreeFile
Open RawFile For Random As FileNum Len = RecordLen
Get FileNum, Position, Transaction
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'LOOP THROUGH EACH RECORD AND CHECK FOR ERRORS IN THE DATA
While EOF(FileNum) <> True
Get FileNum, Position, Transaction
Position = Position + 1
testvar = Asc(Transaction.Spacer)
testvar2 = Asc(Transaction.MachineNum)
If Asc(Transaction.MachineNum) = 0 Then
MsgBox "you have reached the end of the file", vbOKOnly
Exit Sub
End If
If Not IsNumeric(Transaction.MachineNum) Then
MsgBox "there is an error in the file", vbOKOnly
FileError = True
'THIS IS WHERE I WANT TO SAVE THE FILE TO A DIRECTORY!!
Exit Sub
End If
Wend
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
|
|