Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21848

Help Needed on reading Text file lines

$
0
0
Hi All

What i am trying to do is read lines 4 to 16 in a text file sample below for exsample line 5 has as a 0 then put this in chk(5) list box if line 5 is a 1 then put this in lst(5) listbox and so on. this it what i done so far.

Dim intPos As Integer
Dim intPos1 As Integer
Dim intPos2 As Integer
Dim strData5 As String
Dim strData6 As String
Dim strDummy As String
Dim strNum As String
Dim i As Integer
intFile = FreeFile
If Dir("D:\Output.txt") <> "" Then
' Timer2.Enabled = False
Open "D:\Output.txt" For Input As intFile
Line Input #1, strDummy
Line Input #1, strDummy
Line Input #1, strDummy
Line Input #1, strDummy
Line Input #1, strData5
Line Input #1, strData6

intPos = InStr(strData6, "# P")
intPos = InStr(strData5, "1")
If intPos > 0 Then
intPos1 = InStr(intPos + 3, strData6, " ")
intPos2 = InStr(intPos + 1, strData5, " ")
If intPos1 > 0 Then
strNum = Mid$(strData6, intPos + 3, intPos1 - (intPos + 3))
lst(CInt(strNum)).AddItem strData6
If intPos2 > 0 Then
strNum = Mid$(strData5, intPos + 2, intPos2 - (intPos + 2))
chk(CInt(strNum)).AddItem strData5
Close #intFile
End If
End If
End If
End If
End Sub


Text File Sample

line 1 Check V0500
line 2 # Check routine
line 3 # PUMA EOL
line 4 0
line 5 1
etc 1
etc 1
etc 1
etc 0
etc 0
etc 0
etc 0
etc 1
etc 1
etc 0
etc 0
line 14 1
line 15 1
line 16 1
line 17 # P2 PUMA EOL.CHR 29/11/2012 - 09:58:07
fff


regards
steve

Viewing all articles
Browse latest Browse all 21848

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>