Help: Convert HEX to Unsigned?

i have searched all over the help and tryed all the convert examples but they never convert hex values to the right number, it always leaves them as integer.

this is what i want

convert 9C to Unsigned -100

i tryed Convert.UInt16(9C) and it just says cannot convert

and System.BitConverter

if anyone knows a command to easily do this please tell ^_^



Answer this question

Help: Convert HEX to Unsigned?

  • cg_greg

    thanks guys i got it working, this is what i used

    Function ar_ConvertToUnsignedInteger%(ByVal Bytes&)

    If Bytes& > 127 Then

    ar_ConvertToUnsignedInteger% = Bytes& - 256

    Else

    ar_ConvertToUnsignedInteger% = Bytes&

    End If

    End Function


  • Voodoo45

    "Assuming you just want to convert bytes in the range &H00..&HFF"

    What other range can there be for bytes



  • Kooki

    Assuming you just want to convert bytes in the range &H00..&HFF:

    Public Function SignextendByte(ByVal value As Integer) As Integer
    If value >= &H80 Then value = value - 256
    Return value
    End Function



  • Tomas R

    I don't know what version of VB you are running but in vs2005 this works:

    Dim b As Byte = &H9C
    Dim c As UShort = Convert.ToUInt16(b)

    There is no Convert.UInt16(b)



  • Svenson21

    Oops, should have said "values" rather than "bytes". Had bytes on the mind...


  • Help: Convert HEX to Unsigned?