|
-
Apr 15th, 2010, 06:38 AM
#1
Thread Starter
New Member
[RESOLVED] help with formatting using string.format
I wish to have Result(3) zero padded on the left so that it's always 2 characters wide. I don't know how to accomplish this. for instance, if Result(2) is 1 and Result(3) is 5, I want it displayed as '1.05'. if Result(2) is 1 and Result(3) is 12, I want it displayed as '1.12'. How can this be accomplished?
Code:
lblVersion.Text = String.Format("{0}.{1}", Result(2), Result(3))
Thanks.
Peter
-
Apr 15th, 2010, 06:47 AM
#2
Re: help with formatting using string.format
Are you looking for this one....
Code:
lblVersion.Text = String.Format("{0}.{1:##}", Result(2), Result(3))
Please mark you thread resolved using the Thread Tools as shown
-
Apr 15th, 2010, 06:51 AM
#3
Thread Starter
New Member
Re: help with formatting using string.format
That didn't seem to work.
Thanks for the suggestion.
Pete
-
Apr 15th, 2010, 06:56 AM
#4
Re: help with formatting using string.format
The # symbol is for optional digits. 0 is for mandatory digits.
-
Apr 15th, 2010, 06:58 AM
#5
Thread Starter
New Member
Re: help with formatting using string.format
Oops! I didn't realize I needed to replace the '##' with '00'. It works now. Thank you for your help.
Peter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|