[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
Re: help with formatting using string.format
Are you looking for this one....
Code:
lblVersion.Text = String.Format("{0}.{1:##}", Result(2), Result(3))
Re: help with formatting using string.format
That didn't seem to work.
Thanks for the suggestion.
Pete
Re: help with formatting using string.format
The # symbol is for optional digits. 0 is for mandatory digits.
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