Unable to get TrimEnd to work

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I have a string that I am trying to strip the last 2 characters that happen
to be a "," and a " ". I am also adding a "<br>" to the end.

When I am done I still have the ", " and also the <br>.

In my asp.net page I do:

trace.warn("Before BenefitsData.Text = " & BenefitsData.Text)
trace.warn("BenefitsData.Text(3) = " &
BenefitsData.Text.Substring(BenefitsData.Text.Length-3,1))
trace.warn("BenefitsData.Text(2) = " &
BenefitsData.Text.Substring(BenefitsData.Text.Length-2,1))
trace.warn("BenefitsData.Text(1) = " &
BenefitsData.Text.Substring(BenefitsData.Text.Length-1,1))
BenefitsData.Text = BenefitsData.Text.TrimEnd("t, ") & "<br>"
trace.warn("After BenefitsData.Text = " & BenefitsData.Text)

I get the following results:

Before BenefitsData.Text = None, 401(K), CafeteriaPlan, Benefits additional
Text,
BenefitsData.Text(3) = t
BenefitsData.Text(2) = ,
BenefitsData.Text(1) =
After BenefitsData.Text = None, 401(K), CafeteriaPlan, Benefits additional
Text, <br>

Why doesn't the TrimEnd work?

Thanks,

Tom
 
tshad said:
I have a string that I am trying to strip the last 2 characters that happen
to be a "," and a " ". I am also adding a "<br>" to the end.

When I am done I still have the ", " and also the <br>.
[...]
BenefitsData.Text = BenefitsData.Text.TrimEnd("t, ") & "<br>"

Enable 'Option Strict'!

Use the code below instead:

\\\
.... = BenefitsData.Text.TrimEnd(" "c, ","c)
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top