Results 1 to 7 of 7

Thread: [RESOLVED] Another Complicate Question..

  1. #1

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Resolved [RESOLVED] Another Complicate Question..

    this time....

    i m looking to open a txt file and then search a line "Content-Disposition: inline" and then after this all text will be added to Text1 ( text area ) until the line says '------=_Part_'

    Note : ------=_Part_ is not a complete line so i need it to search this word in line only....

    Means :

    i need all text to be added between line says 'Content-Disposition: inline' and line says'------=_Part_'
    Muhammad Furqan Attari.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Another Complicate Question..

    If you use the code I posted in your other thread to input it into an array of lines, you could do this:
    VB Code:
    1. ' lines = Split(buffer, vbNewLine)
    2. Dim i As Long
    3.  
    4. Const PHRASE1 = "Content-Disposition: inline"
    5. Const PHRASE2 = "------=_Part_"
    6.  
    7. Dim line1 As Long: line1 = -1
    8. Dim line2 As Long: line2 = -1
    9.  
    10. For i = 0 To UBound(lines)
    11.     If (lines(i) = PHRASE1) Then
    12.         line1 = i + 1
    13.         Exit For
    14.     End If
    15. Next i
    16.  
    17. For i = 0 To UBound(lines)
    18.     If (InStrB(1, lines(i), PHRASE2)) Then
    19.         line2 = i - 1
    20.         Exit For
    21.     End If
    22. Next i
    23.  
    24. If ((line1 <> -1) And (line2 <> -1)) Then
    25.     For i = line1 To line2
    26.         Text1.SelPos = 65535
    27.         Text1.SelText = lines(i) & IIf(i <> line2, vbNewLine, vbNullString)
    28.     Next i
    29. End If

    There are slightly better ways, but that's pretty much the simplest.
    Last edited by penagate; Dec 11th, 2005 at 06:53 AM.

  3. #3

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Re: Another Complicate Question..

    now it gives compile error... Next without For ? and highlitghs Next from Next i
    Muhammad Furqan Attari.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Another Complicate Question..

    sorry... fixed

  5. #5

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Re: Another Complicate Question..

    now another Compile Error... Method or Member Data not Found highlights .SelPos From Text1.SelPos
    Muhammad Furqan Attari.

  6. #6

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Re: Another Complicate Question..

    well penagate i also have a situation.... TXT file is as :

    ------=_Part_12444_3233909.1134292044561
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    afdjdfsd

    ------=_Part_12444_3233909.1134292044561
    Content-Type: text/html; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    afdjdfsd

    ------=_Part_12444_3233909.1134292044561--

    'afdjdfsd' is message i want to get it to a Text1.Text but it can be multilined so i can't calculate lines

    this come twice so may be it can also cause problem
    Muhammad Furqan Attari.

  7. #7

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Re: Another Complicate Question..

    i understood it....
    going to add to you reputation

    Thanks Alot

    i did it like :-

    For i = 0 To UBound(lines)
    If (lines(i) = PHRASE1) Then
    line1 = i + 3
    Exit For
    End If
    Next i

    For i = 0 To UBound(lines)
    If (InStrB(1, lines(i), PHRASE2)) Then
    line2 = i - 2
    Exit For
    End If
    Next i
    Muhammad Furqan Attari.

Posting Permissions

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



Click Here to Expand Forum to Full Width