?
Solved

How to convert values

Posted on 2012-09-19
6
Medium Priority
?
323 Views
Last Modified: 2012-09-19
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
0
Comment
Question by:cmdolcet
  • 3
  • 3
6 Comments
 
LVL 83

Assisted Solution

by:CodeCruiser
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         "

.PadRight(16, " ")

?
0
 

Author Comment

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

Author Comment

by:cmdolcet
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 83

Expert Comment

by:CodeCruiser
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

by:cmdolcet
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)
                                USL.PadLeft(4, "0")
                            End If


Which will do nothing on changing the string.
0
 
LVL 83

Accepted Solution

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

USL = USL.Replace(".", "").PadLeft(4, "0")
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question