convert string to hexadecimal

rodneyb

Registered User.
Local time
Today, 15:11
Joined
Jul 3, 2003
Messages
84
I have a procedure that writes to a file and the file has to have these hexadecimal values in it (xxH means xx hexadecimal):

98H
01H
00H
1CH
0AH
20H


How can I get these values onto the file?


Thanks.
 
Fizzio,

I have already tried but the hex function expects a number where as some of the values that I provided are not numbers.

Do I need to convert the values I have provided to numbers first?
 
Rodney,

What exactly is your input? This isn't an EBCDIC converstion
is it?

You might want the: MyHex = Hex(ASC(SomeThing))

Wayne
 
Hi Wayne,

What's EBCDIC?

I guess what I need is to know what the string values are for the hex values that I provided. for example:

Hex("Some String Value") = 98hexadecimal

In your example this would work if I knew what the "SomeThing" is that would give me the hex values.
 
Rodney,

No fair, I asked you first!

Seriously, very your output is a stream of hex values - Very easy!
Your input stream is undefined - Is it a file, a table, ????

If we know the input, the rest is easy.

Wayne
 
The values I provided are hard coded at various points as I am writing strings to the file. For example 1C(hex) is a field separator and 0A(hex) is inserted at the end of every line.

I don't understand - how is it easy?


Thanks.
 
Rodney,

If you were converting memo fields into hex strings, it would be
easy. If you were reading a file and converting its contents into
hex it would be easy.

If I don't know where input the comes from, and in what format,
it is not easy.

Wayne
 
Last edited:
Wayne,

here is a sample piece of code that I am using to write to a file:

Print #1, "DOM" & <FS> & TempList.Fields("TLGRef").Value & <FS> & <LF>

where <FS> is the field separator 1C(hexadecimal) that I need to insert onto the file I'm writing to. Simarlarly <LF> is the end of line separator 0A(hexadecimal).

I don't know what you mean when you say you don't know where the input comes from. If I knew what the character conversion of the hex values are then that would solve my problem and I could replace <FS> & <LF> with those values.


Thanks.
 
Rodney,

Your first line of your file is:

DOM<FS>.....<FS><LF>

Where ..... is whatever the contents of TempList.Fields("TLGRef")
is.

That looks nothing like your first example.

This appears to be one print line per field, but not in hex, as
opposed to one hex char per line as in the example.

So, I'm guessing that you are reading a recordset. There is
probably a correlation between the DOM and the contents to the
field FLGRef.

Maybe the next field will be:

FOG<FS>.....<FS><LF>

Where ..... represents the contents of field "TLGFog".

Wayne
 
Rodney,

Your first line of your file is:

DOM<FS>.....<FS><LF>

Where ..... is whatever the contents of TempList.Fields("TLGRef")
is.

That looks nothing like your first example.

This appears to be one print line per field, but not in hex, as
opposed to one hex char per line as in the example.

So, I'm guessing that you are reading a recordset. There is
probably a correlation between the DOM and the contents to the
field FLGRef.

Maybe the next field will be:

FOG<FS>.....<FS><LF>

Where ..... represents the contents of field "TLGFog".

Wayne
 
I don't understand what you are getting at Wayne.

"DOM" and TempList.Fields("TLGRef").Value are just string values. They are irrelevant to my problem of trying to hard code a string value which is equal to 1C(hexadecimal) and the other hexadecimal values I have provided in the initial thread.


All I need to know is what these hexadecimal values are in string format:

98
01
00
1C
0A
20


Thanks.
 
Rodney,

Oh .....

I get it now, all we need to do is create a hex to decimal
function.

98h = Chr(152)
01h = Chr(1)
00h = Chr(0)
1Ch = Chr(28) - FS
0Ah = Chr(12) - LF
20h = Chr(32)

I need to get to a computer with Access to either find or
write a function. In the interim, I think that this is a
work-around:

Code:
Print #1, "DOM" & Chr(28) & TempList.Fields("TLGRef").Value & Chr(28) & Chr(12)

Wayne
 
Fantastic.

I will give it a try and let you know how I get on.

Thanks for persevering with me Wayne. I really appreciate it.
 
Rodney,

98h = Chr(152) = 9x16 + 8
01h = Chr(1) = 1
00h = Chr(0) = 0
1Ch = Chr(28) = 2x16 + 8
0Ah = Chr(10) = 10
20h = Chr(32) = 2x16

Is that all of them? I don't know how you intend to
use them:

Dim FS As String
FS = Chr(28)

We'll work on it ...
Wayne
 

Users who are viewing this thread

Back
Top Bottom