Output Ascii 0x02 as part of record

L

LLcoolQ

I am writing an interface file to a vendor. The requirements say:

Format of the text: Text must be in the format as you would like it to
appear without embedded newline characters. Instead of newline
characters, use ASCII character 0x02. A blank like would be
represented by two 0x02 characters in a row.

I am having a hard time figuring out how to output this. i have tried
a few things such as

Dim twoAsbyte As Byte = &H2

my output has a "2" wherever i put it instead of an unprintable
character.

So the text would look like:

This is a lineone0x02this is line two0x020x02this is line 4

where 0x02 would really display unprintable characters

Thanx
 
M

Martin H.

Hello LLcoolQ,
characters, use ASCII character 0x02. A blank like would be
represented by two 0x02 characters in a row.

this is not an ASCII text, but a binary as every character with a value
less than 32 (space) is unprintable. Therefore, you might want to write
the file in binary mode.

You can (like in traditional VB) use the "Open" command or to use the
BinaryWriter class ("How to: Read and Write to a Newly Created Data File
" gives you an example how to do it).

Best regards,

Martin
 
D

Dick Grier

Hi,

All characters below decimal 127 (&H7F) are ASCII. You do not need to do
anything special with them. In VB 0x02 is Chr(2).

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
D

Dick Grier

Hi,

All characters below decimal 127 (&H7F) are ASCII. You do not need to do
anything special with them. In VB 0x02 is Chr(2). Example:

Dim STX As String = Chr(2)

STX is the ASCII character called StartOfText. This character is used by
some systems as a marker to indicate the start of a text string. Another
common character is ETX (Chr(3)) EndOfText, which might be used to indicate
the end of a string. These characters do not print, but they still are
ASCII text characters and may be used as part of a String variable.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 

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