Solved

# How to convert values

Posted on 2012-09-19
Medium Priority
323 Views
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.

0
Question by:cmdolcet
• 3
• 3

LVL 83

Assisted Solution

CodeCruiser earned 1200 total points
ID: 38413429
>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         "

?
0

Author Comment

ID: 38413444
how can I change the 2.00 to 0200?
0

Author Comment

ID: 38413481
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

LVL 83

Expert Comment

ID: 38413758
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

Author Comment

ID: 38415092
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)
End If

Which will do nothing on changing the string.
0

LVL 83

Accepted Solution

CodeCruiser earned 1200 total points
ID: 38415139
I would change that code to

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Integration Management Part 2
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
###### Suggested Courses
Course of the Month17 days, 12 hours left to enroll