I read line by line a txt file with a fso.
during the loop if a condition
pseudo code:
if instr(sline,"genova")>0 then
copy and append the current line in a txt file in c:\mydir\genova.txt
end if
note:
in mydir i just have all possible name of instr name for example:
genoma.txt
milano..txt
...
lazio.txt
COPY LINE INTO TXT FILE BAsED varible
-
- PlatinumLounger
- Posts: 4616
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 80247
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: COPY LINE INTO TXT FILE BAsED varible
Code: Select all
Dim f As Integer
If InStr(sline, "genova") > 0 Then
f = FreeFile
Open "C:\mydir\genova.txt" For Append As #f
Write #f, sline
Close #f
End If
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 80247
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: COPY LINE INTO TXT FILE BAsED varible
Alternatively, if you have a variable CITTA, and you assign the name of a city to it in the loop:
Code: Select all
Dim f As Integer
Dim CITTA As String
...
CITTA = ...
f = FreeFile
Open "C:\mydir\" & CITTA & ".txt" For Append As #f
Write #f, sline
Close #f
...
Best wishes,
Hans
Hans