Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 628
  • Last Modified:

How to remove the last character from string

Hi,
I want to remove the last character from string
Ex: I have a string 4.000% I want to remove % from string and want to use 4.000 in the code.

Thanks
0
KavyaVS
Asked:
KavyaVS
  • 2
3 Solutions
 
CodeCruiserCommented:
Simplest thing is to substring

Dim newstr As String = oldstr.Substring(0, oldstr.Length - 1)
0
 
CodeCruiserCommented:
If you know the character you want to remove, you can also use replace

newstr = oldstr.Replace("%", "")
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You can also remove specific characters from only the end with TrimEnd():

    str = str.TrimEnd("%")
0
 
KavyaVSAuthor Commented:
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now