convert string to integer (hex)

  • Thread starter Thread starter Panhuber Astrid
  • Start date Start date
P

Panhuber Astrid

hi!

can anyone please give me a hint, how to convert a hex-string to an integer?

I know how to convert a decimal string (such as "51", "27", ...):
n = System.Convert.ToInt32(str);

But how to convert a hex string (such as "4C" or "0x4C")? If I use the same
function, it throws me an exception.



Thanks in advance,

astrid
 
The following should work:-

n = Int32.Parse("4C", NumberFormat.HexNumber);


Peter
 
...or the ever so gentle:

n = val("&h" & "4C")

even works in the good old VBDOS ;)

Jacco.
 
hi!

thank you - this one works for me:
n = Int32.Parse(str, System.Globalization.NumberStyles.HexNumber);

thanks,
astrid
 
Back
Top