1 (edited by lemodizon 2022-05-17 08:27:20)

Topic: How to calucate two fields (solved.. thanks JB)

Hello everyone,

I'm newbie in MDV. i created a simple form and try MDV, my question is how can i calculate the two fields in my form.


amount = Qtty * Unit cost

once the user entered the qtty and unit cost it will automatic display the amount.

hope you can help me.

thanks in advance.

Post's attachments

Attachment icon twofield.JPG 29.49 kb, 64 downloads since 2022-05-17 

-lemodizon

Re: How to calucate two fields (solved.. thanks JB)

Hello lemodizon

Suppose there are text fields containing the product price (edCost) and quantity (EDQ), and we need to calculate the total (edTotal).

procedure CalculateTotal;
begin
    Form1.edTotal.Value := Form1.edCost.Value * Form1.edQ.Value;                  // We perform the calculation
end;

procedure Form1_edQ_OnChange (Sender: string);
begin
    CalculateTotal;
end;

procedure Form1_edCost_OnChange (Sender: string);
begin
    CalculateTotal;
end;


begin

end.

This can be a clue

JB

3 (edited by lemodizon 2022-05-17 07:50:38)

Re: How to calucate two fields (solved.. thanks JB)

Hi JB,

Thanks for the clue. it works.

my question is do i have to change the syntax in the procedure part "String" coz the original is "ToObject" i changed it to "String"

in the last part of the script is this part of syntax

begin
end.

looks like end of the whole program?

procedure CalculateTotal;
begin
    Form1.edTotal.Value := Form1.edCost.Value * Form1.edQ.Value;                  // We perform the calculation
end;

looks like a function or method i'm not sure.


how do you fliter the text field in the MDV if the user forget to enter a data.?

is there a if else condition in MDV.


Sorry for my questions coz i don't have any idea on how MVD scripts works.

Thanks JB

-lemodizon