Hey fellows, i have a simple problem this time :) i'm just coding around to get some routine and practice, so i decided to make a simple calculator, but i can't figure out how i save a value vor my adding after i got it from the editbox here's what i got i set the two input strings to 0 .data input1 dd "0" input2 dd "0" when u click calculate: .ELSEIF ax==IDC_CALC invoke GetDlgItemText,hDlg,IDC_EDIT1,addr buffer,512 mov input1,buffer invoke GetDlgItemText,hDlg,IDC_EDIT2,addr buffer,512 mov input2,buffer add input1,input2 invoke SetDlgItemText,hDlg,IDC_RESULT,addr input1 I think the problem is that i can't store the value from the buffer into a variable, is there a way to define two buffers and add them up after ? Regards Typhoon
Posted on 2001-03-31 19:46:00 by Typhoon
Theres a couple of problems here. First

mov input2,buffer
you can't do a memory to memory move in assembly. You have to do something like the following
mov eax, buffer
mov input1, eax
Although this won't work in this case as buffer is a string, not a number. Perhaps the best thing I can do here is show you how to convert the string to number, then you can add it.

.model flat, stdcall
option casemap :none   ; case sensitive
include  \masm32\include\windows.inc
include  \masm32\include\user32.inc
include  \masm32\include\kernel32.inc
include  \masm32\include\gdi32.inc
include  \masm32\include\masm32.inc

includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\gdi32.lib
includelib  \masm32\lib\masm32.lib

buffer db 512 dup(?)
input1 dword ?
input2 dword ? ; note dword not db


invoke GetDlgItemText,hDlg,IDC_EDIT1,addr buffer,512
invoke atodw, addr buffer ; convert the string to a dword

mov input1, eax ; the number is returned in eax, as in most
                ; procedures

invoke GetDlgItemText,hDlg,IDC_EDIT2,addr buffer,512
invoke atodw, addr buffer ; convert the string to a dword

add eax, input1 ; note that seen as the second value is in 
                ; eax we can just add input1 to it.

; Now before we can output the value it must be converted
; into a string
invoke dwtoa, eax, addr buffer
invoke SetDlgItemText,hDlg,IDC_RESULT,addr buffer
This isn't too hard once you get used to it. Also remember that this only works integers, if you want to use floating point values then read the tutorial I've just finished. You'll find the link in a thread call FPU tutorials.
Posted on 2001-03-31 20:07:00 by Zadkiel
In your case, since the input will always be numeric, you can call GetDlgItemInt instead. That is, if the numbers are integers.
Posted on 2001-03-31 20:10:00 by Iczelion
cool thanks guys, that works just fine i tried both ideas and i'm making efforts every minute regards
Posted on 2001-03-31 20:19:00 by Typhoon