How to convert values

I need to convert a value from 2.00 to 0200 the same can be said for 10.00 to 1000

I also need to know how I can change a text string so if the incoming text string is say "Point 1" and I need it to have 16 characters How could I change it to have "Point 1         "

All these variables are String datatypes.

Thanks in advance
cmdolcetAsked:
Who is Participating?
 
CodeCruiserCommented:
I would change that code to

USL = USL.Replace(".", "").PadLeft(4, "0")
0
 
CodeCruiserCommented:
>for 10.00 to 1000

.Replace(".", "")

?

> say "Point 1" and I need it to have 16 characters How could I change it to have "Point 1         "

.PadRight(16, " ")

?
0
 
cmdolcetAuthor Commented:
how can I change the 2.00 to 0200?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
cmdolcetAuthor Commented:
Sorry I wasn't as clear as possible on the second example. I need to have 16 characters in total, so If I have the Example "Point 1" ( 7 characters) I need to add in (9) spaces after the 1.

However the name could be anything how could I easy count the number characters and apply the remaining set of spaces to the total of 16 characters.
0
 
CodeCruiserCommented:
PadRight function will pad enough number of spaces to make it long enough (given number of characters).

For 2.00 to 0200, I think you would remove . and then use PadLeft(4, "0") to add 0 at start.
0
 
cmdolcetAuthor Commented:
OK so for example the value 2.00 or 10.00 I need for it to be shown as 0200 or 1000

I have the following code:

 If USL.Contains(".") Then
                                USL.Remove(2, 0)
                                USL.PadLeft(4, "0")
                            End If


Which will do nothing on changing the string.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.