|
-
Dec 11th, 2005, 05:58 AM
#1
Thread Starter
Addicted Member
[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_'
-
Dec 11th, 2005, 06:37 AM
#2
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:
' lines = Split(buffer, vbNewLine)
Dim i As Long
Const PHRASE1 = "Content-Disposition: inline"
Const PHRASE2 = "------=_Part_"
Dim line1 As Long: line1 = -1
Dim line2 As Long: line2 = -1
For i = 0 To UBound(lines)
If (lines(i) = PHRASE1) Then
line1 = i + 1
Exit For
End If
Next i
For i = 0 To UBound(lines)
If (InStrB(1, lines(i), PHRASE2)) Then
line2 = i - 1
Exit For
End If
Next i
If ((line1 <> -1) And (line2 <> -1)) Then
For i = line1 To line2
Text1.SelPos = 65535
Text1.SelText = lines(i) & IIf(i <> line2, vbNewLine, vbNullString)
Next i
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.
-
Dec 11th, 2005, 06:51 AM
#3
Thread Starter
Addicted Member
Re: Another Complicate Question..
now it gives compile error... Next without For ? and highlitghs Next from Next i
-
Dec 11th, 2005, 06:53 AM
#4
Re: Another Complicate Question..
sorry... fixed
-
Dec 11th, 2005, 06:56 AM
#5
Thread Starter
Addicted Member
Re: Another Complicate Question..
now another Compile Error... Method or Member Data not Found highlights .SelPos From Text1.SelPos
-
Dec 11th, 2005, 07:14 AM
#6
Thread Starter
Addicted Member
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
-
Dec 11th, 2005, 08:21 AM
#7
Thread Starter
Addicted Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|