[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_'
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.
Re: Another Complicate Question..
now it gives compile error... Next without For ? and highlitghs Next from Next i
Re: Another Complicate Question..
Re: Another Complicate Question..
now another Compile Error... Method or Member Data not Found highlights .SelPos From Text1.SelPos
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
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