Hi, I have done a search so please don't tell me to! :D
I have this in a text box:

<MenuItem version="1.0">
<item_text>
<TEXT default_lang="en" str=""></TEXT>
</item_text>
<item_help>
</item_help>
<item_icon>
<RIGHT str="softkey1.png" />
</item_icon>
<item_action>
<ACTION type="JAVA" suite_name="" suite_vendor="" entry_point=""></ACTION>
</item_action>
</MenuItem>
PNG

   
IHDR   F      1e   bKGD      	pHYs        tIME8R  IDATx՘nxDRK(l%q:MnE>@AoH	R;cg EEJ$Egf(ޕ`ؘ̾׿xx9 x   <
 !c 3t}  :tuowO 0 2 4ټ?17|kCq|D 8]6)  j AsFG'y3ym*{
?=9T`(& ;(b`΁(R9zhn	2nO}pg^FȨnU CL.(H u\S{˿,=m?hUsX%sk}[OeT[b!
2 96C3̅sƋGy\ϝo[eSK!Mlz	csq D$Svbx  ̛ FȜs*3NndBj8hT6kVNYaS
O*&R'Ӣh@Ya dnD   r^	G	2ԩK[_Td$饏Yt$qIѴQi'$3É45\BZA7sqCQ^3@b
&O0[ Ȕh ˅'j|
VhD"aHyglݹ4t<wZ di
xY5VvO.#1emGU$80y.]]~AZ!r{
Z8t0?yv+:MCdžudyAcǝ˿f6Kvf-λΰiEnO~?֚-{QZy ȁmTDږ;'v>͐uW%[iRRtï7wOe1yNU-Z5xֳ澎&<wYw_VQ8:8|9c4:aޅ!;loo7E&y͍u6x%KS3
7uy_0/Xd|5t[,56p20j44=N/
\-4Egn.|_7:>׉.@X2J xɦ
Y*@RV-Nf0c of'P4Zkw#AD0Lp̢n
бh֪$$t$VA0'H-r{%A"ix`b0DVQ1n{b߂Vu8!VHk;Jvw Z#]do(FSl#j`d>^	ʢuF2Q"w*5>CaYڄr yo/]]EBݗ
Jѝ0%t"b;ܑ
Fus̛~mB4*]/w6NBB@KnXo<tg/~(z'=#N$["ɼDܸJpM}dtBa=сsJXpkţ@b3a?7ҾN-Maz^^\N$/_``Z8fw]c6 L0&Ec,gD<D=86䜴:yHl AxCZ?0    IENDB`

Please could somebody provide me with some code (I am not new to VB but I wouldn't know where to start with this) which removes the PNG line
Thanks
luke

which removes the �PNG line

You mean everything after </MenuItem> string?

Dim TempPos As Integer

TempPos = TextBox1.Text.LastIndexOf("</MenuItem>", System.StringComparison.OrdinalIgnoreCase)
' Found?
If TempPos >= 0 Then
  ' Remove the rest of the content
  TextBox1.Text = TextBox1.Text.Substring(0, TempPos + "</MenuItem>".Length)
End If

You mean everything after </MenuItem> string?

Dim TempPos As Integer

TempPos = TextBox1.Text.LastIndexOf("</MenuItem>", System.StringComparison.OrdinalIgnoreCase)
' Found?
If TempPos >= 0 Then
  ' Remove the rest of the content
  TextBox1.Text = TextBox1.Text.Substring(0, TempPos + "</MenuItem>".Length)
End If

Thanks so much for your assistance but no I just want to remove the ?PNG line
Thanks

This should provide "visually" desired result

' Locate PNG string                                                         
Dim TempPos As Integer                                                      
                                                                            
TempPos = TextBox1.Text.IndexOf("PNG", System.StringComparison.Ordinal)     
' Found?                                                                    
If TempPos > 1 Then                                                         
  ' Remove PNG and two chars before and one char after it                   
  TextBox1.Text = TextBox1.Text.Substring(0, TempPos - 2) & _               
    TextBox1.Text.Substring(TempPos + 5, TextBox1.Text.Length - TempPos - 5)
End If

You may have to adjust the numbers a bit and make sure you don't get out of the bounds, but that's the basic idea.

Since you're dumping binary data, it would be better to read it originally to a byte array. The PNG file starts:

00000000h: 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 ; ‰PNG........IHDR

Locate the bytes 89 50 4E 47 0D 0A and remove them before converting byte array to text.

This article has been dead for over six months. Start a new discussion instead.