Importing txt files.
I need some advice.
I am using the follwoing code to pull in information form a text file
Dim TransResult As String
Dim TerLoop As String
Dim TransValue As Currency
Dim cashback As Currency
Dim TipValue As Currency
Dim Track2 As String
Dim ExpiryD As String
Dim IssueN As String
Dim StartD As String
Dim TranTime As String
Dim Merchent As String
Dim Terminal As String
Dim CardName As String
Dim FloorLimit As String
Dim EFTSeq As String
Dim AuthCode As String
Dim VoiceNum As String
Dim Message As String
Dim StepOver As String
Open "C:\Information.txt" For Input As #1
While Not EOF(1)
Input #1, TransResult, TerLoop, TransValue, cashback, TipValue, Track2, ExpiryD, IssueN, StartD, TranTime, Merchent, Terminal, CardName, FloorLimit, EFTSeq, AuthCode, VoiceNum, Message, StepOver
Wend
Label1.Caption = TransResult
Label2.Caption = TerLoop
Label3.Caption = TransValue
Label4.Caption = cashback
Label5.Caption = TipValue
Label6.Caption = Track2
Label7.Caption = ExpiryD
Label8.Caption = IssueN
Label9.Caption = StartD
Label10.Caption = TranTime
Label11.Caption = Merchent
Label12.Caption = Terminal
Label13.Caption = CardName
Label14.Caption = FloorLimit
Label15.Caption = EFTSeq
Label16.Caption = AuthCode
Label17.Caption = VoiceNum
Label18.Caption = Message
Close #1
it work fine when the files are just text but sometime I will get a entry in the file as a -nn and it then creates a runtime error 62.
nn = a number (eg 57)
But if the first line is change to
Dim TransResult As Integer it will read in the -04 file no problems
my question is HOW can I set this up to allow BOTH types of files to be processed?
Example file are
0,1,15.99,,,,,,,,,,,,,,,Transaction processed Fine
-42,1,15.99,,,,,,,,,,,,,,,Card on hot list
0,1,5.99,,,,,,,,,,,,,,,Transaction processed Fine
0,1,1.99,,,,,,,,,,,,,,,Transaction processed Fine
0,1,0.99,,,,,,,,,,,,,,,Transaction processed Fine
0,1,115.99,,,,,,,,,,,,,,,Transaction processed Fine
0,1,815.99,,,,,,,,,,,,,,,Transaction processed Fine
-98,1,,,,,,,,,,,,,,,,Unknow PoS location
Thanks for your help guys.
Drew

