ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unwanted characters saving to fie (https://www.excelbanter.com/excel-programming/420688-unwanted-characters-saving-fie.html)

Fan924

Unwanted characters saving to fie
 
I have a column of digital numbers that I convert yo binaty and samv
to file "SaveBinary.bin". When I convert it back to hex, I have an
extra "0D 0A" added onto the back of the file. This is an extra
carriage return and linefeed the Print # Statement added. I tested it
and it is not part of my data string. This is part of the Print #
Statement? Is there anything I can do?

Sub SaveBinary()
Dim r As Range, c As Range
Dim BinaryString As String
BinaryString = ""
Open "C:\My Documents\SaveBinary.bin" For Output As #1
<snip
Print #1, BinaryString
Close #1
End Sub


Rick Rothstein

Unwanted characters saving to fie
 
If you put a semi-colon at the end of Print or Print # statement, the
newline will be suppressed. If you are printing in a loop, you have to make
sure to do this to the last line only. Change your statement to this...

Print #1, BinaryString;

(Note the semi-colon on the end)

--
Rick (MVP - Excel)


"Fan924" wrote in message
...
I have a column of digital numbers that I convert yo binaty and samv
to file "SaveBinary.bin". When I convert it back to hex, I have an
extra "0D 0A" added onto the back of the file. This is an extra
carriage return and linefeed the Print # Statement added. I tested it
and it is not part of my data string. This is part of the Print #
Statement? Is there anything I can do?

Sub SaveBinary()
Dim r As Range, c As Range
Dim BinaryString As String
BinaryString = ""
Open "C:\My Documents\SaveBinary.bin" For Output As #1
<snip
Print #1, BinaryString
Close #1
End Sub



Fan924

Unwanted characters saving to fie
 
Thanks! Very grateful. ;)


All times are GMT +1. The time now is 06:38 AM.

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