Android Question Int to Hex or Slider.value to Hex

namnach

Member
Licensed User
Longtime User
Hi

i find many to Hex to Decimal but not Decimal to Hex...

is there any way for a simple convert a integer

..127

to the hex

..7F

i need the 7F as String in a later second variable

i mean that will do in second for me....
Dim StrValue as String
Dim ValString as Int

StrValue = ValString

Thank you!
 

derez

Expert
Licensed User
Longtime User
There are probably simpler ways but this works:
B4X:
Dim bc As ByteConverter
Dim val(1) As Int
val(0) = 127
Log(bc.HexFromBytes(bc.IntsToBytes((val))))
It gives 0000007F
 
Upvote 0

namnach

Member
Licensed User
Longtime User
thank you for answere ...

...yes!!! it works!!! thank you!!!
..

I try

B4X:
Dim bc As ByteConverter
Dim val(1) As Int
Dim d2 as string
val(0) = 127
d2 = bc.HexFromBytes(bc.IntsToBytes((val)))

LOG(d2.Substring(d2.Length -3 + 1 ))

It gives 7F

is there are shorter way for 7F ?

thanks!!
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If it is an int you could use Bit.ToHexString(intvalue) i think
 
Upvote 0
Top