ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unwanted spaces (https://www.excelbanter.com/excel-programming/298759-unwanted-spaces.html)

Glen Millar

Unwanted spaces
 
Hi,

I am using the Open statement to load a file for input, and an Print#
statement to output to a different text file.

Open ("C:\Documents and Settings\millarg\Desktop\result.txt") For Output As
#2
T$ = Chr$(9)
Print #2, "Year"; T$; "Month"; T$; "Day"; T$; "Rain"; T$; "Lat"; T$;
"LongTd"

This particular part of code puts a heading line in the file. I then go on
to open the Input file, and do various tests. However, later on when I print
actual data, I get unwanted spaces between tab characters.

T$ = Chr$(9)
If Yr = MyYear And mnth = _
MyMonth And dy = MyDay Then
Print #2, Yr; T$; mnth; T$; dy; T$; Rain; T$; MyLat; T$; MyLong
Close #1
GoTo BackUp
Else: Input #1, Yr, mnth, dy, cumday, Rain, MyLat, MyLong

End If

Yet, if I test variables such as Yr, mnth or dy while code is running, there
are no spaces in these variables. But printing them, even if forcing a tab
character, results in spaces. Following si an example of an output:

Year Month Day Rain Lat LongTd
1975 12 21 152 148.10 23.95
1978 2 1 155.1 148.10 23.95
2002 1 5 198.6 148.10 23.95

When I paste it in here, there is only one character in the heading row,
equal to a tab in the original file. But there are multiple characters in
the actual data, which did not come from the original data.

Is there some way around this, or a test I can do to get rid of these
unwanted spaces? Any ideas?

--

Regards,

Glen Millar
Microsoft PPT MVP
http://www.powerpointworkbench.com/
Please tell us your ppt version, and get back to us here
Remove spaces from signature
Posted to news://msnews.microsoft.com



Glen Millar

Unwanted spaces
 
Hi,

Worked around it by converting to text and deleting leading spaces. Thanks.
Interesting that an integer with a length of 4 has a string length of 5!

--

Regards,

Glen Millar
Microsoft PPT MVP
http://www.powerpointworkbench.com/
Please tell us your ppt version, and get back to us here
Remove spaces from signature
Posted to news://msnews.microsoft.com

"Glen Millar" <glen @ powerpointworkbench.com wrote in message
...
Hi,

I am using the Open statement to load a file for input, and an Print#
statement to output to a different text file.

Open ("C:\Documents and Settings\millarg\Desktop\result.txt") For Output

As
#2
T$ = Chr$(9)
Print #2, "Year"; T$; "Month"; T$; "Day"; T$; "Rain"; T$; "Lat"; T$;
"LongTd"

This particular part of code puts a heading line in the file. I then go on
to open the Input file, and do various tests. However, later on when I

print
actual data, I get unwanted spaces between tab characters.

T$ = Chr$(9)
If Yr = MyYear And mnth = _
MyMonth And dy = MyDay Then
Print #2, Yr; T$; mnth; T$; dy; T$; Rain; T$; MyLat; T$;

MyLong
Close #1
GoTo BackUp
Else: Input #1, Yr, mnth, dy, cumday, Rain, MyLat, MyLong

End If

Yet, if I test variables such as Yr, mnth or dy while code is running,

there
are no spaces in these variables. But printing them, even if forcing a tab
character, results in spaces. Following si an example of an output:

Year Month Day Rain Lat LongTd
1975 12 21 152 148.10 23.95
1978 2 1 155.1 148.10 23.95
2002 1 5 198.6 148.10 23.95

When I paste it in here, there is only one character in the heading row,
equal to a tab in the original file. But there are multiple characters in
the actual data, which did not come from the original data.

Is there some way around this, or a test I can do to get rid of these
unwanted spaces? Any ideas?

--

Regards,

Glen Millar
Microsoft PPT MVP
http://www.powerpointworkbench.com/
Please tell us your ppt version, and get back to us here
Remove spaces from signature
Posted to news://msnews.microsoft.com





mudraker[_225_]

Unwanted spaces
 
Glen

I beleive your problem would have been caused by an integer value hav
provision for +- symbol which and will show as a space if the number i
positiv

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


Glen Millar

Unwanted spaces
 
Hi,

That could be spot on! I worked around it by converting to a new srting
variable, and deleting the first character. I needed to get these spaces out
as the data goes into ArcGis and it hates spaces between tabs. Thanks.

--

Regards,

Glen Millar
Microsoft PPT MVP
http://www.powerpointworkbench.com/
Please tell us your ppt version, and get back to us here
Remove spaces from signature
Posted to news://msnews.microsoft.com

"mudraker " wrote in message
...
Glen

I beleive your problem would have been caused by an integer value have
provision for +- symbol which and will show as a space if the number is
positive


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





All times are GMT +1. The time now is 03:47 AM.

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