Reputation: 1017
my string is for example : 111
i want to remove 1
from my string
result:
11
what i have tried:
Replace(string, "1", "")
result : Null
Upvotes: 0
Views: 107
Reputation: 11233
I guess there are several ways to do so.
Two of them are: (Use RIGHT method)
Dim s As String = "1111"
Dim newstring1 As String = Strings.Right(s, s.Length - 1)
and: (Use substring method)
Dim s As String = "1111"
Dim newstring2 As String = s.Substring(1)
But make sure to check length of string
to avoid getting ArgumentException
.
Upvotes: 0
Reputation: 1964
Replace has a Count parameter, which says how many times to do the string replacement. So what you want is:
Replace(string, "1", "", 1, 1)
http://msdn.microsoft.com/en-US/library/bt3szac5(v=VS.80).aspx
Upvotes: 0
Reputation: 137352
Look at the Count
argument to the Replace()
function.
http://msdn.microsoft.com/en-us/library/bt3szac5(v=vs.80).aspx
Replace("11111", "1", "", , 1)
It allows you to limit the number of replacements.
Upvotes: 3