Hi friends,
i have a text file and i want to read each line and parse the word and put it in to variable field
but when "while looping process" i want to read next line for condition.
i want to put variable Add1, Add2, Add3, Reg.No, Name2.
Problem is that when i ReadLine contain "Address" then i parse Add1 but Add2, Add3 is optional so i want to know when ReadLine read the current line that time Nextline contain "[" this sign or not if "NO" then it will put in Add2, if "YES" then don't go to Add2 and Add3
For more detail i also attached Sample text file and also put the code which i done
Sub CopyReadLineFile()
Dim EndFound, FoundName As Boolean
Dim FileLoc As String
Dim FN As Integer
Dim N As Long
Dim LinData() As Variant
Dim StartFound As Boolean
Dim StartNo,EndNo As String
Dim sAdd1, sAdd2, sAdd3, sState, sPincode,
Dim ReadLine
StartNo = Trim("BQE ID")
EndNo = ""
Fileloc = "C:\Documents and Settings\My Documents\Sample.txt
"
FN = FreeFile
Application.ScreenUpdating = False
Open FileLoc For Input As #FN
Do While Not EOF(FN)
Line Input #FN, ReadLine
If Trim(Left(ReadLine, 7)) = "Address" Then
sAdd1 = Trim((Mid(ReadLine, WorksheetFunction.Find("Address", ReadLine) + 7, Trim(Len(ReadLine)) - Trim(WorksheetFunction.Find("Address", ReadLine) + 7))))
End if
Loop
Close #FN
End If
Bookmarks