Results 1 to 7 of 7

Read next Line

Threaded View

  1. #1
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Read next Line

    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
    Attached Files Attached Files
    Last edited by mohan.r1980; 12-10-2010 at 06:51 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1