Unwanted spaces

G

Glen Millar

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
 
G

Glen Millar

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
 
M

mudraker

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
 
G

Glen Millar

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top