After get text the number has 1 or 2 digit, how can i add "0" if there is only 1 digit

after get text the number has 1 or 2 digit, how can i add “0” if there is only 1 digit

For example
2155,9 has only one digit after “,” so i want to add “0” if is it the case

image

@Soudios

you want add 0 in place of 9 like 2 155,9 output as 2 155,0

or

you want output as 2 155,90

@Shiva_Nikhil

i need this “you want output as 2 155,90”

Hi @Soudios

Try this

InputText="2155,9"
String.Join(",", InputText.Split(","c).Select(Function(part) If(part.Length = 1 AndAlso Char.IsDigit(part(0)), part & "0", part)))

Hope this helps!!

@Soudios

For example input is “2155,92”

@Soudios

booloutput=system.text.RegularExpressions.Regex.IsMatch(inputstr,“\d+\s\d+,\b\d{1}\b”)

gives true if there is any single digit

check this once

Hi @Soudios
Try this:

text="2155,9"
text = String.Join(",", text.Split(","c).Select(Function(x) If(x.Length = 1, "0" + x, x)))

Hope it helps!!

its not worlking well
image

Hi @Soudios

What is the input you are giving based on that will modify the syntax.

Regards,

the zero needs to be at the end not before the last number

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.