Link to home
Start Free TrialLog in
Avatar of randyg
randyg

asked on

Hex

I am using Visual C++ 5.0 and am in Dialog mode.

I am trying to convert numbers to Hex. I am using this statement and would like to know how to display the number in hex.

SetDlgItemInt(IDC_STATIC,m_number);

I would also like to know how to recieve a hex number from and EDIT box.

Thanks
Randy
ASKER CERTIFIED SOLUTION
Avatar of Answers2000
Answers2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Answers2000
Answers2000

Right you can can use SetDlgItemText to place text on a static or edit. (simply replace IDC_STATIC with the id of the control)

To get the current text from an edit use GetDlgItemText, then use sscanf to get convert a hex number to a integer

char szOutput[256] ;
GetDlgItemText( IDC_EDIT, szOutput, sizeof szOutput ) ;
int nNumber ;
sscanf( szOutput, "%x", &nNumber ) ;


incidentally %x means use lower case letters in hex numbers, %X means use upper case

I think that's everything you need ?
I agree with Answers2000,  itoa would be a good option, I have written a base x program, which converts any number to any base 2-36.  input a number in anybase and output. If you want it you can have it, just E-mail me.  g_dutoit@hotmail.com.  


Avatar of randyg

ASKER

Great answers!!!!!

Thanks