How to remove 0 (zero) from start but not from end

how to remove 0 from start but not from end.

Var. GetText = the registered value is 0004560.

I have used Split once to get just number from the string value…
GetText = Split(GetText,". ")(1)
Answer I got is 0004560.

Now I want to remove the 0 from Left side the Dot from end means the Zero from start but the zero 0 from end I want to keep as its the right value…

Result I want 4560…

can someone help… Thanks


Can you try TrimStart method as the following?



no its not working


In my environment, it works as the following.


or if there are some whitespace at the beginning of the string, the following might be better.



Hi @Latif

Try out this

out_variable= variable.Replace(“000”,"")

Robinnavinraj S

Hi @Latif ,

Can you show the result of the different options?
I mean you could also use substring, but the other options (trimstart / replace ) also work.

Can you start with putting the original value between quotes? " 004560" , Like Yoichi said there might be whitespaces there at the beginning.

If al else fails you can invoke code, and then split the original value in chars and decide what you want to keep. Would be a bit of a workaround as I don’t see why the other options should not work.

For Each c As Char In Input
If c.ToString.IsNumeric And newval.Length=0 Then
If c.ToString=“0” Then
Console.WriteLine(“Loosing another 0”)
newval= c.ToString
End If
Else If c.ToString.IsNumeric And newval.Length>0 Then
newval=newval+ c.ToString
Console.WriteLine("What else is in this string? "+c.ToString)
End If

Hi @Latif ,

How about this one?

1 Like

i have a number 123456 and I want to add “-” inbetween after 4 number from right side.
Length of number is either 10 or 12 but I want “-” after 4 number from right side…

like 123456-7894
like 10123456-7891

can someone help… thanks

HI @Latif

Please use insert string function

str_Input = “123456789”
str_Input.Insert(str_Input.Length-4,"-") will insert the character “-” 4 characters from right side


1 Like

Thanks for the big help.