I am converting an integer to string using the str() function
However, I noticed that the str() function would return an extra character to the string.
For example, MsgBox(Len(str(1)))
would return 2.
What is the extra character being appended?
MsgBox (Len(Trim(Str(1))))
Siddharth Rout 2012-04-04 10:27
From Excel 2010 help:
"When numbers are converted to strings, a leading space is always reserved for the sign of number. If number is positive, the returned string contains a leading space and the plus sign is implied."
And sure enough this statement returns True in the debug window:
? left(str(1),1) = " "
Easiest way to find out:
MsgBox(Asc(Right(Str(1),1)))
As pointed out in this answer you should use the format()
function.