Question

Cant figure this out, why does this is spliting in 3 parts instead of 2?

myRichTextboxEx.Rtf = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1043\deflangfe1043\deftab708{\fonttbl{\f0\fnil\fcharset0 Segoe UI;}{\f1\fswiss\fprq2\fcharset0 Verdana;}{\f2\fmodern\fprq1\fcharset0 Lucida Console;}{\f3\froman\fprq2\fcharset0 Times New Roman;}}  {\colortbl ;\red0\green0\blue255;}  {\*\generator Riched20 6.3.9600}\viewkind4\uc1   \pard\nowidctlpar\sl276\slmult1\tx1276\tx2130\tx3124\f0\fs18           \f1\fs36\par    \pard\nowidctlpar\sl276\slmult1\tx3000\f2\fs17             Eemplein 20\line          3812 EA Amersfoort\line         {{\field{\*\fldinst{HYPERLINK www.kingoftheribs.nl }}{\fldrslt{www.kingoftheribs.nl\ul0\cf0}}}}\f2\fs17\line            033-8887088\par    \pard\nowidctlpar\sl276\slmult1\qc\tx3000\par    \pard\nowidctlpar\sl276\slmult1\tx3000\line B.J. van Logtestijn\line Prins Frederiklaan 57C   \line 3818KB \line Amersfoort\line T1:06=41191965 T2: T3:\line\b   \par  \fs30 Bon #1\line\b0\fs18\line\line\line 1 x Durum Chicken\tab       3,95 \line\line 1 x Turkse pizza (lamacun)\tab       1,95 \line\li
ne 1 x Turkse pizza sla en saus\tab       2,50 \line     \i Groot ben&Jerry's (3,5)\i0\line\line 1 x Gegra. aardappel\tab       3,00 \line\line 1 x Kapsalon menu kebab Medium\tab       5,95 \line\line 1 x Drumsticks Menu 3st\tab       5,95 \line\line 1 x Kinder Menu Ribs\tab       3,75 \line\par  Totaal:\tab      30,55\line Korting:\tab       0,00\line\fs20 Te voldoen:\fs18\tab      30,55\par  Betaald met:\tab <BEDRAGBETAALDMET>\par  Wisselgeld:\tab     -30,55\par   \b\fs24\line\b0\fs18 Btw 6,00 % over 30,55:\tab       1,73 \b\fs24\line\b0\fs18 Btw 21,00 % over 0,00:\tab       0,00\par  \par  Aflevertijd:  \par  \fs17 Betaalwijze:\b\fs24  Contant\b0\fs17  \par  \par  \f1 29-10-2013   29-10-2013 16:47:50\par  \f2                          \fs24\par    \pard\nowidctlpar\sl276\slmult1\qc\tx3000\fs22 Bedankt voor uw bestelling\par  en eet smakelijk!!!\f1\lang19\par    \pard\nowidctlpar\sl276\slmult1\tx3000\par  <CUTHERE>-----------------------------------\par  \b\f2\fs30\lang1043 Ordernummer 1\par    \pard\nowidctl
par\sa200\sl276\slmult1\b0\f3\fs22 --------------------------------------------------\par  }  "

Dim SplitRTFmessage As String() = myRichTextboxEx.Rtf.Split("<CUTHERE>")
Was it helpful?

Solution

You are using the wrong overload (this one is expecting a Char not a String). The one you are looking for is:

Dim SplitRTFmessage As String() = myRichTextboxEx.Rtf.Split(New String() {"<CUTHERE>"}, StringSplitOptions.None)

This is the right way (one of the alternatives you have) to use a string as a separator and thus delivers the right result (2 parts).

OTHER TIPS

What's causing this is that the overload you're using for split is actually an array of characters and not a string. As a result, it's splitting on <.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top