Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have 2 text boxes with numbers in them. how do I subtract them and put the result in a third text box.

I tried this

.data

gettext1            DB 100 DUP(?)
gettext2           DB 100 DUP(?)
gettext3            DB 100 DUP(?)

.code

LOCAL pmem1  :DWORD

        invoke GetDlgItemText,hWin,MeasuredlengthXtextbox,esi,100

    invoke GetDlgItemText,hWin,MeasuredlengthYtextbox,edi,100

    sub esi,edi 

    mov pmem1,esi   

    invoke lstrcpy,addr gettext1,pmem1

    invoke SetDlgItemText,hWin,ResultlengthXtextbox,addr gettext3

when I try this code it shows up nothing in the textbox

thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
144 views
Welcome To Ask or Share your Answers For Others

1 Answer

First, the third parameter to GetDlgItemText is a pointer to a buffer to hold the string. A register will not work. You need to load esi and edi with the addresses of buffers, say gettext1 and gettext2.

Second, you cannot add strings. The number 1 you see on the screen is not really a number, but an ASCII version of the number.

You need to get the text, convert to a number, subtract, then convert back to a string to use with SetDlgItemText.

To make your life easier, just use GetDlgItemInt which will convert the number string to a number and return in eax, then use SetDlgItemInt


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...