First, excuse my bad english ..
i have a edit control, i capture text with "GetDlgItemTextA" into a buffer. It works ok.
But now i want to convert from decimal to hexadecimal .. ¿how? .. i try this:
buffer1 db 5 dup(0)
buffer2 db 5 dup(0)
format db "%05lX"
call GetDlgItemTextA, IDC_EDITTEXT, offset buffer1,5
mov eax,offset buffer1
mov eax,
call wsprintfA,offset buffer2,offset format,ax
....
But it doenst work ... when a move buffer1 offset to eax and then eax, i obtain some extrange values ...
help! :)
P.D (TASM source)
The problem is that you do not need to convert decimal to hexadecimal string, but a decimal STRING to a hexadecimal string. So you'll either have to convert it from a string to a value, then convert to a hex value, or use GetDlgItemInt instead of GetDlgItemText, this func returns the converted value.
Thomas
i need to convert from decimal value to hexadecimal value .. i mean the user will enter a number in the edittext .. never strings.
if your user has typed "15" in your edit control, you will receive in AX value 3135h (ascii values). So you must first transform this to binary value 15 before using this as parameter for wsprintf. use atol() or sscanf() before.
japheth
how i can pass ascii value to binari? or directly to hexa ? ... 8)
Have you tried "GetDlgItemInt"?
The GetDlgItemInt function translates the text of a specified control in a dialog box into an integer value.
It could be exactly what your looking for!
Mirnono .. the user enters a decimal number (1,2,3,4 .... ) i need to translate this decimal number to hexadecimal but the number is in a buffer (check first post)
japheth`s post sounds the way ... i need a small routine to translate the ASCII value from the buffer to binary and then pass it to wsprintfA to transform in hexadecimal.
Any1 has this routine?
Thats what Mirno was suggesting, GetDlgItemInt gets the string value form the edit box and converts it to a dword for you.
Then wsprint can convert that to Hex, or the dwtohex routine in the masmlib should do this also.
mmm ... i dont understand very well this ..
1º) the users must enter a PORT NUMBER (for winsock use)
2º) the users enter for example: 21
3º) i caputre with "GetDlgItemTextA" (¿GetDlgItemInt?) and stores in a buffer (in the first case)
4º) i need to translate this number to hex for winsock usage.
buffer1 db 5 dup(0)
buffer2 db 5 dup(0)
format db "%05lX"
call GetDlgItemTextA, IDC_EDITTEXT, offset buffer1,5
mov eax,offset buffer1
mov eax,
here i need the BINARY VALUE ... i obtain ASCII VALUE :(
call wsprintfA,offset buffer2,offset format,ax
add esp,12
5º) now i need the HEX in EAX !!! to pas it as parameter to "htons" function.
mov eax,offset buffer2
mov eax,
AGAIN ... ASCII VALUE ! .
push eax
call htons
This will drive me crazy ... :-(
ok .. it works know (GetDlgItemInt roolz) ;)).
Thx a lot.
??? you don't need to convert numbers
to hex before you make use of apis...
if the user enters port:666 all you have
to do is convert this value from ascii
to a number. for example say i want to
store the number 666 in eax... eax will
contain 29a in hex and 666 decimal get it?
unknow,
There are a few basic here that seem to have been missed in your
question, when you type data into an edit control, it is TEXT
data. _drcmda has told you the simple basics, you don't need to
multiply convert the data, all you need to do is convert the TEXT
to DWORD format and use it as the port number that you need.
HEX display is a TEXT format so if you wanted the user to type in
the port number in HEX, you would need a different conversion but
that is probably not what you want.
Just convert the TEXT data from the edit control directly to DWORD
and you have the port number to work with. As you are using TASM,
if you want to use any of the code in the MASM32 library, you will
need to convert it to TASM first.
Regards,
hutch@pbq.com.au