I have a text file that I need to add data into each line based on a if/then function...
Below is a sample of the text file... Position 8 is where I need to look and position 14 is where I want to put the result of the true part of the if/then function..
Sample:
3719 N256UP KAMA
4030 N676UP KUNK
4331 N462UP KAMA
So something like:
If left(strLine,8) = 2 then
left(strLine,14) = 1
elseif left(strLine,8) = 6 then
left(strLine,14) = 3
This is what I am working with - I keep striking out however..
Sub VisitTallyTest()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
Dim strNewfile As String
Set db = CurrentDb
strImportFile = "D:\UPSDATA\VisitTallyMain.txt"
strNewfile = "D:\UPSDATA\VisitTally.txt"
Open "D:\UPSDATA\VisitTally.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 8) Like "1" Then
strType = Left(strLine, 14) = 5
Print #2, Left(strType, 175)
End If
Loop
Close #1
Close #2
Kill strNewfile
'VisitTallyMainSpec
End Sub
Below is a sample of the text file... Position 8 is where I need to look and position 14 is where I want to put the result of the true part of the if/then function..
Sample:
3719 N256UP KAMA
4030 N676UP KUNK
4331 N462UP KAMA
So something like:
If left(strLine,8) = 2 then
left(strLine,14) = 1
elseif left(strLine,8) = 6 then
left(strLine,14) = 3
This is what I am working with - I keep striking out however..
Sub VisitTallyTest()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
Dim strNewfile As String
Set db = CurrentDb
strImportFile = "D:\UPSDATA\VisitTallyMain.txt"
strNewfile = "D:\UPSDATA\VisitTally.txt"
Open "D:\UPSDATA\VisitTally.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 8) Like "1" Then
strType = Left(strLine, 14) = 5
Print #2, Left(strType, 175)
End If
Loop
Close #1
Close #2
Kill strNewfile
'VisitTallyMainSpec
End Sub