|
-
Aug 23rd, 2005, 02:12 PM
#1
Thread Starter
Fanatic Member
[resolved] odd str() behavior in Access2000
Hello,
I've noticed something odd about the str() function in Access2000. When I do a str(12345) or the like, the resulting string is " 12345". Note the space in front of the number. Does anyone know why that happens?
Thanks.
Last edited by rickford66; Aug 23rd, 2005 at 02:43 PM.
-
Aug 23rd, 2005, 02:33 PM
#2
Re: odd str() behavior in Access2000
That is the nature of the Str function, the space is there as a "placeholder" for the + sign (if the number is negative, - will be shown instead of a space).
If you want to convert a number to a string (without the space at the front) use CStr instead
-
Aug 23rd, 2005, 02:35 PM
#3
Thread Starter
Fanatic Member
Re: odd str() behavior in Access2000
Thanks. I understand, but it seems silly. Why would I need a place holder? It seems that more often than not, I wouldn't. If I needed one, I could just put one in manually. Hmmm.
-
Aug 23rd, 2005, 02:46 PM
#4
Re: [resolved] odd str() behavior in Access2000
It depends what you are doing with the number, if you are printing it in a column along with lots of other numbers (some of which are negative) then they will line up properly.
Despite what most people think, Str is not designed for conversion, it is for formatting as I described. CStr is the function for converting to a string (just like CInt is for converting to Integer)
-
Aug 23rd, 2005, 02:55 PM
#5
Thread Starter
Fanatic Member
Re: [resolved] odd str() behavior in Access2000
Ah yes. (showing my inexperience) Thanks.
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
|