Hex to decimal conversion

Paladium

Member
Licensed User
Longtime User
Hi there,

I got another question. I need to convert hex values into decimal values. In .net I use val and "&H" plus the hex value. That's all. How do I manage this in B4A? Please help. Thanks a lot.

Markus
 

Paladium

Member
Licensed User
Longtime User
Thanks for the quick reply.

Tried it but get a "numberformatexception".

Small example:
PHP:
Sub ed3_TextChanged (Old As String, New As String)
   Dim aaa As Int
   aaa = "0xab12"
   Msgbox(aaa,"")
End Sub
 
Upvote 0

Paladium

Member
Licensed User
Longtime User
Same when using edit text:

PHP:
Sub ed3_TextChanged (Old As String, New As String)
   Dim aaa As Int
   aaa = 0x & ed3.Text
   Msgbox(aaa,"")
End Sub

PHP:
Compiling generated Java code.          Error
B4A line: 69
aaa = 0x & ed3.Text
javac 1.6.0_23
src\com\asdbsfdbsdfb\binary.java:259: hexadecimal numbers must contain at least one hexadecimal digit
_aaa = (int)(Double.parseDouble(BA.NumberToString(0x)+mostCurrent._ed3.getText()));
                                                  ^
1 error
 
Upvote 0

RichardBernard

Member
Licensed User
Longtime User
If the data type Int has the range : 4bytes signed: -2147483648 to 2147483647
Then why can't I get this code to run:
B4X:
Dim s As String
Dim i As Int
s = "80000002"  ' 0h80000002 = -2,147,483,646
i = Bit.ParseInt(s,16)
Comp_Gain_Offset.Text = i

I get the error:

I would appreciate your help,
Richard
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…