Differences in Format method between VB6 an VB.NET
Visual Basic
4
Posts
3
Posters
0
Views
1
Watching
-
-
It doesn't work because the "000" format specifier is for numeric values only. You passed in a string of characters ("80"). It will work if you do
Dim str As String = Format(80, "000")
returns "080".
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
I could solve that by adding String before format function. So: Format("80", "000") returns "000" String.Format("80", "000") returns "80"
Regards, Diego F.
Diego F. wrote:
String.Format("80", "000") returns "80"
That's because you are specifying a format string without any formatting what so ever.
String.Format("80", "fubar")
also returns "80". What you want is:80.ToString("000")
orString.Format("{0:000}", 80)
--- single minded; short sighted; long gone;