Converting value to HEX

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
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?
 
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
 
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) ?
 
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.
 
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?
 
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()
 
Back
Top