ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ampersand operator unexpectedly trims? (https://www.excelbanter.com/excel-programming/297119-ampersand-operator-unexpectedly-trims.html)

Woody[_3_]

ampersand operator unexpectedly trims?
 
In the immediate window, I input:

? "_" & " abc " & "_"

and it returns:

_ abc _


Why did it knock off all but one of the spaces off the right side of the
middle string?

Thanks,
Woody

Bob Kilmer[_2_]

ampersand operator unexpectedly trims?
 
It looks like it has something to do with the underscores. For instance:

?"_ _"
_ _

?"' '"
' '

?"_ '"
_ '

?"" Space(10) "<"
<


? "_" Space(10) "_"
_ _

? "_"; Space(10); "_"
_ _

? "_" Tab(10) "_"
_ _

? "" Tab(10) "<"
<



using Win 2K, Excel 2002

"Woody" wrote in message
.121...
In the immediate window, I input:

? "_" & " abc " & "_"

and it returns:

_ abc _


Why did it knock off all but one of the spaces off the right side of the
middle string?

Thanks,
Woody




mudraker[_201_]

ampersand operator unexpectedly trims?
 
Woody

you only have one space before abc and one after abc which is what the
return result shows

"_" & " abc " & "_"

gives a string of

_ abc _


---
Message posted from http://www.ExcelForum.com/


Bob Kilmer[_2_]

ampersand operator unexpectedly trims?
 
how do you explain this?

? "_"; Space(10); "_"
_ _

or this?

?"_ _"
_ _

"mudraker " wrote in message
...
Woody

you only have one space before abc and one after abc which is what the
return result shows

"_" & " abc " & "_"

gives a string of

_ abc _


---
Message posted from http://www.ExcelForum.com/




Woody[_3_]

ampersand operator unexpectedly trims?
 
mudraker wrote in
:

Woody

you only have one space before abc and one after abc which is what the
return result shows

"_" & " abc " & "_"

gives a string of

_ abc _


---
Message posted from http://www.ExcelForum.com/


no, there are 3 spaces before and after "abc". This should make it more
obvious:

?"_" & space(3) & "abc" & space(3) & "_"
_ abc _


mudraker[_209_]

ampersand operator unexpectedly trims?
 
I don't know the correct answer but I beleive it has to do with VB
using _ as the symbol theat the line of code is continued on to th
next line and VBA automatically removing all extra spaces betwee
operators

--
Message posted from http://www.ExcelForum.com


onedaywhen

ampersand operator unexpectedly trims?
 
This one's worthy of inclusion in j-walk's 'Excel Oddities':

http://j-walk.com/ss/excel/odd/index.htm

--


All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com