Topic: Convert hex to Int..
I'm using the com-port and get hex values, which i need to convert to integer values.
Which function should i use??
hextostr doesn't work...
neither inttostr with '$'
Any idea would be appreciated... Thank you
Maik
My Visual Database → General → Convert hex to Int..
I'm using the com-port and get hex values, which i need to convert to integer values.
Which function should i use??
hextostr doesn't work...
neither inttostr with '$'
Any idea would be appreciated... Thank you
Maik
Hello lupo1st,
There is no embedded function to convert Hexadecimal to Integer because there is no need for it : hex are just strings.
3877 is an integer with a value and $F25 is the same value but presented in a different way.
You tried IntToStr while you should have used the other one : StrToInt
All you have to do is treat that hex value as a string and use the StrToInt function to convert it to integer, keeping the $ or it won(t be recognized.
In the following example, I setup and edit field to receive the hex value and a button to convert it :
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
hex : String;
int : Integer;
begin
hex := Form1.edHex.Text; //Hex value with $ sign
int := StrToInt(hex);
ShowMessage(IntTostr(int));
end;
Of course, I had to convert again the int to an Str to display it but after conversion. I you use your converted value right away, you don't need to re-convert it.
Hope this helps
Cheers
Math
My Visual Database → General → Convert hex to Int..
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi