Converting value to HEX

C

cmdolcet69

I have a program that saves values in the following format:
4096,4095,4044,3900,3812,........... to a text file.

I need to know how to convert the 4096 into a HEX value in this
format: 0x40 + 0x96. This format require me to seperate the Hi bits
and Lo bits.

Can anyone help me out?
 
G

Guest

You can use the Hex function to convert decimal to Hex.

To seperate hi and lo byte, there are quite a few sample code on the net. I
found the following:

Public Function HiByte(ByVal wParam As Integer)
HiByte = wParam \ &H100 And &HFF&
End Function
Public Function LoByte(ByVal wParam As Integer)
LoByte = wParam And &HFF&
End Function

See if it helps
 
C

cmdolcet69

You can use the Hex function to convert decimal to Hex.

To seperate hi and lo byte, there are quite a few sample code on the net. I
found the following:

Public Function HiByte(ByVal wParam As Integer)
HiByte = wParam \ &H100 And &HFF&
End Function
Public Function LoByte(ByVal wParam As Integer)
LoByte = wParam And &HFF&
End Function

See if it helps

--
Rgds,
Anand
VB.NET MVPhttp://www.dotnetindia.com







- Show quoted text -

what is the wParam in (ByVal wParam As Integer) ?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

cmdolcet69 said:
what is the wParam in (ByVal wParam As Integer) ?

That's the word value that you want to split into two bytes.


Here's another method:

Dim bytes As Byte() = BitConverter.GetBytes(3900)

bytes(0) contains low byte and bytes(1) contains high byte.
 
C

cmdolcet69

That's the word value that you want to split into two bytes.

Here's another method:

Dim bytes As Byte() = BitConverter.GetBytes(3900)

bytes(0) contains low byte and bytes(1) contains high byte.

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

How do I deisplay what is inside bytes?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

cmdolcet69 said:
How do I deisplay what is inside bytes?

You render the value into a string and disply the string.

Example:

MyLabel.Text = bytes(0).ToString()
 

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